Naravel.Scheduling
0.2.0
dotnet add package Naravel.Scheduling --version 0.2.0
NuGet\Install-Package Naravel.Scheduling -Version 0.2.0
<PackageReference Include="Naravel.Scheduling" Version="0.2.0" />
<PackageVersion Include="Naravel.Scheduling" Version="0.2.0" />
<PackageReference Include="Naravel.Scheduling" />
paket add Naravel.Scheduling --version 0.2.0
#r "nuget: Naravel.Scheduling, 0.2.0"
#:package Naravel.Scheduling@0.2.0
#addin nuget:?package=Naravel.Scheduling&version=0.2.0
#tool nuget:?package=Naravel.Scheduling&version=0.2.0
Naravel.Scheduling
Naravel task scheduling: a fluent, named schedule run by a hosted service, with overlap and one-server guards over Naravel.Cache locks.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Scheduling |
| Targets | .NET 10 |
| Needs | Naravel.Cache, which NuGet installs with it |
What you get
- A fluent, named schedule.
schedule.Call("name", handler)followed byEveryFiveMinutes(),DailyAt(8, 0),WeeklyOn(...)orCron("*/20 9-17 * * 1-5"). - A hosted service runs it. It wakes once a minute and starts what is due, and each run gets its own DI scope.
- Guards over cache locks.
WithoutOverlapping()andOnOneServer()run on Naravel.Cache locks. - Time zones. Times are UTC unless a task calls
InTimeZone(zone).
Quick start
builder.Services.AddNaravelCache(builder.Configuration); // from Naravel.Cache: the lock driver for WithoutOverlapping and OnOneServer
builder.Services.AddNaravelScheduling(schedule =>
{
// Task names are yours: ASCII letters, digits and . _ : - , at most 100 characters.
schedule.Call("prune-sessions", (sp, ct) => sp.GetRequiredService<SessionPruner>().RunAsync(ct)) // SessionPruner is your own service
.EveryFiveMinutes()
.WithoutOverlapping();
schedule.Call("daily-digest", (sp, ct) => sp.GetRequiredService<Digest>().SendAsync(ct)) // so is Digest
.DailyAt(8, 0)
.OnOneServer();
});
If the host was stopped, the missed minutes are skipped, not replayed; there is no catch-up in this version.
WithoutOverlapping() skips a run while the previous one still holds its lock; the lock expires after one hour (SchedulingOptions.OverlapTtl), so a crash cannot block the task for good. OnOneServer() needs a lock driver that all instances share (Redis or Memcached): with the Memory cache driver every instance would run the task, so the host refuses to start.
Learn more
- Scheduling: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Cronos (>= 0.13.0)
- Microsoft.Extensions.Configuration (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- Naravel.Cache (>= 0.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md