Rask.Jobs
0.24.0
See the version list below for details.
dotnet add package Rask.Jobs --version 0.24.0
NuGet\Install-Package Rask.Jobs -Version 0.24.0
<PackageReference Include="Rask.Jobs" Version="0.24.0" />
<PackageVersion Include="Rask.Jobs" Version="0.24.0" />
<PackageReference Include="Rask.Jobs" />
paket add Rask.Jobs --version 0.24.0
#r "nuget: Rask.Jobs, 0.24.0"
#:package Rask.Jobs@0.24.0
#addin nuget:?package=Rask.Jobs&version=0.24.0
#tool nuget:?package=Rask.Jobs&version=0.24.0
Rask.Jobs
Durable background jobs for a Rask app — enqueued work that runs off the request thread, stored in the app's own database, with no broker or Redis.
- Mark a type
IJoband write anIJobHandler<TJob>to do the work — found at build time, nothing to register. Underneath it travels through Rask.Cqrs as a command, so a handler written asICommandHandler<TJob>keeps working. - A background
JobProcessorpolls theJobtable and runs each due job — at-least-once, with exponential-backoff retries up toMaxAttempts(then left as a dead letter for inspection). - Delayed (
await Jobs.Enqueue(job).In(24.Hours),.At(when)) and durable recurring (o.Run<T>().Every(1.Hour),.Daily.At(3, 0),.Weekly.On(DayOfWeek.Monday).At(9, 0)) jobs — recurring runs are tracked in the DB, so a restart never double-runs them. Read the schedule back fromJobsOptions.RecurringJobs. - Metrics on the
Rask.Jobsmeter: processed / failed / dead-lettered counters, a duration histogram, and pending / dead-letter gauges.rask.jobs.deadlettersis the one to alert on. - A source generator registers every
IJobtype for reflection-free rehydration on the run path.
Use
public sealed record SendWelcomeEmail(Guid UserId) : IJob;
public sealed class SendWelcomeEmailHandler(IEmailSender email) : IJobHandler<SendWelcomeEmail>
{
public Task Handle(SendWelcomeEmail job) => email.SendWelcomeAsync(job.UserId, Current.Cancellation);
}
// Program.cs
builder.Services.AddRaskCqrs();
builder.Services.AddRaskJobs<AppDbContext>(o =>
{
o.Run<PurgeStaleCarts>().Every(1.Hour);
o.Run<NightlyBackup>().Daily.At(3, 0);
});
// AppDbContext.OnModelCreating: modelBuilder.AddRaskJobs();
// then: rask db add AddJobs && rask db update
// enqueue from anywhere — a handler, a render, a request, another job:
await Jobs.Enqueue(new SendWelcomeEmail(user.Id));
await Jobs.Enqueue(new SendReminder(order.Id)).In(24.Hours);
Register your context as an IDbContextFactory<AppDbContext> (Rask Server sessions are long-lived).
Several instances is safe: each processor leases the batch it claims, so a job runs on exactly one of
them. On SQLite you will still usually run one, because SQLite is single-writer, so the processor claims
work by polling and writing sequentially. Need a job to commit atomically with a business change? Raise a domain event and deliver it with
Rask.Outbox instead — the two pillars are complementary.
Lanes. Jobs.Enqueue(job).InLane(pump.Id): jobs of one lane run one at a time, different lanes side by side - a
ten-minute job holds up its own lane only. Adds the Lane column: rask db add AddJobLane && rask db update.
Await a job's answer. var done = await Jobs.Run(new AtPump(pump.Id)).InLane(pump.Id); stores the job (an
IJob<Done>, handled by an IJobHandler<AtPump, Done>), runs it in its lane on whichever host, and hands back its
answer - or throws JobFailedException with its error; it is tried once. Cancelling the wait (or .Within(2.Minutes)
running out) stops the waiting, never the job. Adds two columns: rask db add AddJobResult && rask db update.
Stop a job, or let it stop itself. await Jobs.Stop(id) cancels a running job's Current.Cancellation on whichever
host runs it (a waiting one never runs); c.Jobs.Limit<AtPump>().After(30.Minutes).IdleFor(5.Minutes) stops it at a
time limit, or when no Jobs.Report(…) came for that long. A stopped job is not failed and not retried, and its lane
moves on at once. await Jobs.Lanes(pumpIds) reads what runs and what waits in many lanes in one query. Adds two
columns: rask db add AddJobStop && rask db update.
A job runs as whoever enqueued it. The row records the signed-in user (Current.UserId) and, in a
multi-tenant app, the tenant; the processor re-enters both before the handler runs, so the handler reads
Current.UserId and filters tenant-scoped tables as the page that enqueued it would have. Upgrading adds the
UserId column: rask db add AddJobUser && rask db update. Job.Where(…) queries the queue with no context of your
own.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Microsoft.EntityFrameworkCore (>= 11.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 11.0.0)
- Rask.Cqrs (>= 0.24.0)
- Rask.Data (>= 0.24.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Rask.Jobs:
| Package | Downloads |
|---|---|
|
Rask.Server
The ASP.NET host for Rask, a full-stack .NET web framework, with every battery: database (SQLite or SQL Server, and PostgreSQL with the Rask.Postgres package, picked by Rask:Database:Provider), mediator and query cache, accounts, background jobs, transactional email, cache, file storage, outbox, operator dashboard, durable logs, Web Push, SQLite snapshots and continuous backup. Renders Rask components with live updates over a WebSocket. RaskApp.Create(args).Run<App>() is the whole Program.cs, and RaskApp.Create(args).Serve() the whole server of a WebAssembly client; app.Configure(c => c.Jobs.Off()) is how an app does without one. Depends on Rask, the shared core. |
|
|
Rask.Dashboard
A built-in operator dashboard for the Rask One Person Framework batteries. Mounts at /_rask and shows the outbox, background jobs, queued mail, cache and stored files from the application's own database — queue depth, dead letters, the errors behind them, stored email previews, the recurring-job schedule, SQLite pragmas and backup status. A live log tail is built in, and becomes a searchable history when Rask.Logging is installed. Panels appear only for the batteries the app actually registered. Protected by an authorization policy that fails closed outside Development. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.24.1-alpha.0.987 | 39 | 11/28/2026 |
| 0.24.1-alpha.0.979 | 39 | 11/28/2026 |
| 0.24.1-alpha.0.972 | 42 | 11/28/2026 |
| 0.24.1-alpha.0.970 | 49 | 11/28/2026 |
| 0.24.1-alpha.0.907 | 47 | 11/27/2026 |
| 0.24.1-alpha.0.902 | 49 | 11/27/2026 |
| 0.24.1-alpha.0.873 | 52 | 11/27/2026 |
| 0.24.1-alpha.0.822 | 52 | 11/27/2026 |
| 0.24.1-alpha.0.782 | 49 | 11/27/2026 |
| 0.24.1-alpha.0.775 | 51 | 11/27/2026 |
| 0.24.1-alpha.0.774 | 56 | 11/27/2026 |
| 0.24.1-alpha.0.770 | 51 | 11/27/2026 |
| 0.24.1-alpha.0.769 | 63 | 11/26/2026 |
| 0.24.1-alpha.0.767 | 51 | 11/26/2026 |
| 0.24.1-alpha.0.766 | 54 | 11/26/2026 |
| 0.24.1-alpha.0.760 | 57 | 11/26/2026 |
| 0.24.1-alpha.0.759 | 56 | 11/26/2026 |
| 0.24.1-alpha.0.757 | 60 | 11/26/2026 |
| 0.24.1-alpha.0.754 | 61 | 11/26/2026 |
| 0.24.0 | 145 | 11/16/2026 |