Rota 1.0.1
See the version list below for details.
dotnet add package Rota --version 1.0.1
NuGet\Install-Package Rota -Version 1.0.1
<PackageReference Include="Rota" Version="1.0.1" />
paket add Rota --version 1.0.1
#r "nuget: Rota, 1.0.1"
// Install Rota as a Cake Addin #addin nuget:?package=Rota&version=1.0.1 // Install Rota as a Cake Tool #tool nuget:?package=Rota&version=1.0.1
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 Corvael 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
- Multiple execution modes.
- Concurrent/parallel execution.
- Consecutive execution.
- Granular control of configuration.
- Microsoft.Extensions.Hosting support.
- Caching.
- Built-in persistent 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 string Name => "HelloWorld";
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
{
public string Name => "HelloWorld";
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)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.