Rota 1.1.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rota --version 1.1.0                
NuGet\Install-Package Rota -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rota" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rota --version 1.1.0                
#r "nuget: Rota, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0-pre 124 9/27/2022
1.1.0 163 9/22/2022
1.0.1 389 9/15/2022
1.0.0 389 9/15/2022