Giter Club home page Giter Club logo

chroniton's Introduction

Build status NuGet

Synopsis

A library for running tasks(jobs) on schedules. It supports:

  • Strongly typed jobs with strongly typed parameters
  • Asynchronous execution
  • Running a single job on multiple schedules
  • Running Multiple jobs on a single schedule
  • Cron schedules
  • Run once and expiring schedules
  • Custom schedules
  • Limiting the number of threads on which work is done
  • Managing behaviors of jobs which run beyond their next scheduled time
  • Dependency Injection initialization
  • Full mocking for unit tests
  • .NET Core

See Wiki and Tutorial for more info. Official site here.

Code Example

    var singularity = Singularity.Instance;

    var job = new SimpleParameterizedJob<string>((parameter, scheduledTime) => 
        Console.WriteLine($"{parameter}\tscheduled: {scheduledTime.ToString("o")}"));

    var schedule = new EveryXTimeSchedule(TimeSpan.FromSeconds(1));

    var scheduledJob = singularity.ScheduleParameterizedJob(
        schedule, job, "Hello World", true); //starts immediately

    var startTime = DateTime.UtcNow.Add(TimeSpan.FromSeconds(5));

    var scheduledJob2 = singularity.ScheduleParameterizedJob(
        schedule, job, "Hello World 2", startTime);

    singularity.Start();

    Thread.Sleep(10 * 1000);

    singularity.StopScheduledJob(scheduledJob);

    Thread.Sleep(5 * 1000);

    singularity.Stop();

In the above example, here's what happens: The first job starts immediately and print's "Hello World" once every second. Five seconds later the second job starts and prints "Hello World2" every second. Five seconds later the first job stops and only the second job is running. Five seconds later, Stop() is called and the second job also stops. Notice the same job is used with multiple schedules with different parameters.

Coming Soon !!!

The above code works with the currently released version. A new version with serialization features is on the way and has been started. There will be some breaking changes. If you'd like to see some of the changes coming, check out the Serialization branch. The core logic for how jobs run will not change, but how jobs get added has. I'm personally very excited to be bringing these changes as it opens up a world of possibilites for the project.

Motivation

This project was inspired for the need to have a strongly typed .NET solution for running tasks on schedules.

Installation

in your nuget package manager:

Install-Package Chroniton

for .NET Core use:

Install-Package Chroniton.NetCore

Contributors

Created by : Leonard Sperry [email protected]

License

Licensed under the MIT License

Changes

V 1.0.3

  • Cron string support
  • XUnit
  • Simplified constructors for SimpleJob and SimpleParameterizedJob

V 1.0.2

  • Support for run once and expiring jobs

V 1.0.1

  • Simplified Singularity by removing one of the main loops.
  • Added .NET Core support

Future Features

  • Serialization
  • Distributed execution

Notes

Unfortunately, .NET Core projects do not yet support referencing Shared Code projects. Therefore, the .NET Core projects in this solution reference all the files in the shared projects directly.

chroniton's People

Contributors

leosperry avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.