Decode.Hosting.Abstractions
3.0.0
dotnet add package Decode.Hosting.Abstractions --version 3.0.0
NuGet\Install-Package Decode.Hosting.Abstractions -Version 3.0.0
<PackageReference Include="Decode.Hosting.Abstractions" Version="3.0.0" />
<PackageVersion Include="Decode.Hosting.Abstractions" Version="3.0.0" />
<PackageReference Include="Decode.Hosting.Abstractions" />
paket add Decode.Hosting.Abstractions --version 3.0.0
#r "nuget: Decode.Hosting.Abstractions, 3.0.0"
#:package Decode.Hosting.Abstractions@3.0.0
#addin nuget:?package=Decode.Hosting.Abstractions&version=3.0.0
#tool nuget:?package=Decode.Hosting.Abstractions&version=3.0.0
Decode.Hosting.Abstractions
Core contracts, options and context models for Decode background workers.
📦 Installation
dotnet add package Decode.Hosting.Abstractions
This package is contracts only — no dependencies beyond the framework. The worker implementation
lives in Decode.Hosting; you normally reference that one, which brings
this in transitively. Reference this package directly when a Domain or Application layer needs to
see WorkerContext without depending on the hosting stack.
🛠️ Components
WorkerOptions
Configuration for a single worker.
public class WorkerOptions
{
public TimeSpan Interval { get; set; } = TimeSpan.FromMinutes(1);
public bool RunOnStartup { get; set; } = true;
public TimeSpan ErrorBackoffDelay { get; set; } = TimeSpan.FromSeconds(5);
public bool SuppressExceptions { get; set; } = true;
}
| Option | Default | Meaning |
|---|---|---|
Interval |
1 minute | Delay between cycles. Must be greater than zero, or the worker fails with a message naming this property. |
RunOnStartup |
true |
Run one cycle immediately instead of waiting for the first interval to elapse. |
ErrorBackoffDelay |
5 seconds | Extra wait after a failed cycle, applied only when SuppressExceptions is true. |
SuppressExceptions |
true |
Keep the worker alive after an unhandled exception. When false, the exception propagates and faults the background service. |
Interval is a delay between cycles, not a fixed schedule: the time a cycle spends running is added
on top. A cycle that takes 20 seconds with a 1 minute interval runs every 80 seconds, not every 60.
WorkerContext
Passed to each cycle, identifying that cycle.
public class WorkerContext(Guid executionId, CancellationToken cancellationToken)
{
public Guid ExecutionId { get; }
public CancellationToken CancellationToken { get; }
}
ExecutionId is a fresh Guid per cycle. It is also written to the cycle's trace span as
worker.execution_id and to the worker's log entries, so a span, a log line and a database record
written during that cycle can all be correlated.
CancellationToken is the host's shutdown token. Pass it down to every async call you make inside a
cycle so that shutdown is not delayed by work in flight.
📖 Usage
These types are only useful together with ScopedPeriodicWorker. See the
Decode.Hosting readme for a complete worker.
using Decode.Hosting.Abstractions;
// A service that needs to know which cycle it is running in, without depending on the host.
public class OrderSweeper(IOrderRepository repository)
{
public async Task SweepAsync(WorkerContext context)
{
await repository.MarkStaleAsync(context.ExecutionId, context.CancellationToken);
}
}
📄 License
MIT License.
| 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Decode.Hosting.Abstractions:
| Package | Downloads |
|---|---|
|
Decode.Hosting
Resilient, scoped, and telemetry-instrumented background worker abstractions for the Decode library ecosystem. |
GitHub repositories
This package is not used by any popular GitHub repositories.