Rota 1.1.0
See the version list below for details.
dotnet add package Rota --version 1.1.0
NuGet\Install-Package Rota -Version 1.1.0
<PackageReference Include="Rota" Version="1.1.0" />
paket add Rota --version 1.1.0
#r "nuget: Rota, 1.1.0"
// Install Rota as a Cake Addin #addin nuget:?package=Rota&version=1.1.0 // Install Rota as a Cake Tool #tool nuget:?package=Rota&version=1.1.0
Rota
A simple yet robust job scheduling library that aims to be simpler and easier to use than Quartz.NET, but also more robust and configurable than other simple schedulers like Coravel while providing sensible default configuration options such that for light use little to no configuration is actually required beyond setting up job schedules.
Rota was heavily inspired by Coravel.
Features
- Job scheduling
- Simple schedule that triggers on an interval.
- Schedule that uses cron expressions.
- Schedule that uses a rate limiter to further restrict exection.
- Complex schedule that can build highly specific schedules without needing to know cron expressions.
- Multiple execution modes.
- Concurrent/parallel execution.
- Consecutive execution.
- Granular control of configuration.
- Microsoft.Extensions.Hosting support.
- Caching & persistence for schedules, and jobs.
- Built-in cache providers.
- JSON
- XML
- MongoDB
- PgSQL
- MySQL/MariaDB
- SQLite
- SurrealDB
- Built-in cache providers.
Quick Start
Rota is available on NuGet.
Manual
Below is a minimal example of a job that prints Hello, World!
to the console every 10 seconds on a manually managed
job scheduler.
using Rota;
using Rota.Jobs;
using Rota.Scheduling;
var scheduler = new JobScheduler();
var everyTenSeconds = Schedule.FromInterval( TimeSpan.FromSeconds( 10 ) ).RunOnceAtStartup();
scheduler.ScheduleJob<HelloWorldJob>( everyTenSeconds ); // HelloWorldJob will execute every 10 seconds
while( !scheduler.IsCancellationRequested )
{
await scheduler.RunJobsAsync(); // run all jobs that are due to be executed
await Task.Delay(
scheduler.Configuration.PollingRate // the interval at which RunJobsAsync() should be called.
);
}
public sealed class HelloWorldJob : IJob
{
public async ValueTask ExecuteAsync( CancellationToken cancellationToken )
=> await Console.Out.WriteLineAsync( "Hello, World!" );
}
Hosted
Below is a minimal example of a job that prints Hello, World!
to the console every 10 seconds using a scheduler
registered to a hosting context. It also demonstrates dependency injection support by using an ILogger
instance to
print to the console.
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Rota.Hosting;
using Rota.Jobs;
using Rota.Scheduling;
var host = Host.CreateDefaultBuilder()
.ConfigureDefaults( args )
.UseConsoleLifetime()
.AddScheduler()
.Build();
host.UseScheduler(
scheduler => {
var everyTenSeconds = Schedule.FromInterval( TimeSpan.FromSeconds( 10 ) ).RunOnceAtStartup();
scheduler.ScheduleJob<HelloWorldJob>( everyTenSeconds ); // HelloWorldJob will execute every 10 seconds
}
);
await host.RunAsync();
public sealed class HelloWorldJob : IJob
{
private readonly ILogger<HelloWorldJob> _logger;
public HelloWorldJob( ILogger<HelloWorldJob> logger ) => this._logger = logger;
public ValueTask ExecuteAsync( CancellationToken cancellationToken )
{
this._logger.LogInformation( "Hello, World!" );
return ValueTask.CompletedTask;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Cronos (>= 0.7.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.2)
- Nito.AsyncEx.Coordination (>= 5.1.2)
- System.Threading.RateLimiting (>= 7.0.0-rc.1.22426.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.