- Notifications
You must be signed in to change notification settings - Fork18
A library for running tasks(jobs) on schedules.
License
leosperry/Chroniton
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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
SeeWiki andTutorial for more info. Official sitehere.
varsingularity=Singularity.Instance;varjob=newSimpleParameterizedJob<string>((parameter,scheduledTime)=>Console.WriteLine($"{parameter}\tscheduled:{scheduledTime.ToString("o")}"));varschedule=newEveryXTimeSchedule(TimeSpan.FromSeconds(1));varscheduledJob=singularity.ScheduleParameterizedJob(schedule,job,"Hello World",true);//starts immediatelyvarstartTime=DateTime.UtcNow.Add(TimeSpan.FromSeconds(5));varscheduledJob2=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.
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 theSerialization 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.
This project was inspired for the need to have a strongly typed .NET solution for running tasks on schedules.
in your nuget package manager:
Install-Package Chroniton
for .NET Core use:
Install-Package Chroniton.NetCore
Created by : Leonard Sperryleosperry@outlook.com
Licensed under the MIT License
- Cron string support
- XUnit
- Simplified constructors for SimpleJob and SimpleParameterizedJob
- Support for run once and expiring jobs
- Simplified Singularity by removing one of the main loops.
- Added .NET Core support
- Serialization
- Distributed execution
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.
About
A library for running tasks(jobs) on schedules.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.