Cronitor.Coravel
6.0.78
dotnet add package Cronitor.Coravel --version 6.0.78
NuGet\Install-Package Cronitor.Coravel -Version 6.0.78
<PackageReference Include="Cronitor.Coravel" Version="6.0.78" />
<PackageVersion Include="Cronitor.Coravel" Version="6.0.78" />
<PackageReference Include="Cronitor.Coravel" />
paket add Cronitor.Coravel --version 6.0.78
#r "nuget: Cronitor.Coravel, 6.0.78"
#:package Cronitor.Coravel@6.0.78
#addin nuget:?package=Cronitor.Coravel&version=6.0.78
#tool nuget:?package=Cronitor.Coravel&version=6.0.78
Cronitor.Coravel
Reports Coravel scheduled jobs to Cronitor: run when the job starts, complete when it succeeds, and fail, with the exception's message, when it throws.
Install
dotnet add package Cronitor.Coravel
The package's major version matches Coravel's: version 6 is for Coravel 6 (6.0.0 or later), on .NET 8, 9 and 10.
Setup
Register Cronitor with .ConfigureCronitor() on the host builder and call AddCronitorCoravel() next to AddScheduler(). Then schedule each job you want reported with ScheduleWithCronitor<TJob>() instead of Schedule<TJob>():
using Coravel;
using Cronitor.Coravel;
using Cronitor.Extensions;
var host = Host.CreateDefaultBuilder()
.ConfigureCronitor((context) => context.Configuration.GetValue<string>("Cronitor:ApiKey"))
.ConfigureServices(services =>
{
services.AddScheduler();
services.AddCronitorCoravel();
services.AddTransient<BackupJob>();
})
.Build();
host.Services.UseScheduler(scheduler =>
{
scheduler.ScheduleWithCronitor<BackupJob>().DailyAt(3, 0);
});
await host.RunAsync();
ScheduleWithCronitor<TJob>() returns what Schedule<TJob>() returns, so the schedule and everything after it, such as .PreventOverlapping(), .When() and .Zoned(), work as usual. The job is created the same way too, so register it as you would for Schedule<TJob>().
Jobs scheduled with Schedule<TJob>() are not reported, so you choose which jobs Cronitor monitors. Only invocable jobs can be reported: a job scheduled as a lambda, with Schedule(() => …), has nothing that names it from one start of the application to the next.
What is reported
Every run of the job is reported: run when it starts, then complete when it succeeds, or fail when it throws, with the exception's message. A job Coravel cancels when the application stops isn't reported as failed: its run is abandoned with the message "The service went offline", so a deploy or restart doesn't make the monitor fail, and Cronitor keeps the run open until the job runs again. A job cancelled while the application keeps running fails with "The job was cancelled". The job's exception still reaches Coravel, so Coravel's own error handling, such as .OnError(), works as before.
A run Coravel skips is not reported, since it never ran: a run skipped by .PreventOverlapping() because the previous run is still going, or by .When() because its condition is false.
Monitor keys
A job reports to the monitor with the same key as its class name, BackupJob above. Give it a key of its own to report to a different monitor, or to keep two schedules of the same class apart:
scheduler.ScheduleWithCronitor<BackupJob>("nightly-backup").DailyAt(3, 0);
The key must follow Cronitor's rules for monitor keys, such as no / and at most 100 characters, so ScheduleWithCronitor() throws when given one that doesn't.
Errors
Reporting never affects your jobs: the start of a run is reported in the background, so a job never waits for Cronitor. If a report can't be sent, the job still runs and keeps its result, and the error is logged through the host's logging. When the application stops, Coravel cancels the jobs still running and waits for them; reports still being sent are then waited for up to five seconds, so the outcome of the last jobs isn't lost.
Without AddCronitorCoravel(), a job scheduled with ScheduleWithCronitor() doesn't run: Coravel reports an error, through .OnError() and its log, that says to call it.
For everything else about the Cronitor client, such as logging and the API key, see the Cronitor README.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.