Appearance
Configuration
GrydJobsOptions
All GrydJobs settings are configured through GrydJobsOptions:
csharp
builder.Services.AddGrydJobs(options =>
{
// ... configuration here
});Connection String
Required. PostgreSQL connection string used by both Hangfire storage and EF Core job metadata.
csharp
options.ConnectionString = "Host=localhost;Database=gryd_jobs;...";Queues
Defines the processing queues. Jobs can be assigned to specific queues for priority management.
csharp
options.Queues = ["critical", "default", "low"];
// Default: ["default"]Queues are processed in order — the first queue listed has the highest priority.
Worker Count
Number of concurrent background workers per server instance.
csharp
options.WorkerCount = 20;
// Default: Environment.ProcessorCount * 2Auto-Register Recurring Jobs
When enabled, scans JobAssemblies at startup for IRecurringJob implementations.
csharp
options.AutoRegisterRecurringJobs = true; // Default: true
options.JobAssemblies = [typeof(MyJob).Assembly];Dead Letter Retention
Number of days to retain dead letter entries before automatic cleanup.
csharp
options.DeadLetterRetentionDays = 30; // Default: 30
// Set to null to disable automatic cleanupRetry Policies
Default Policy
Applied to all jobs without a specific policy:
csharp
options.DefaultRetryPolicy = new RetryPolicyOptions
{
MaxRetries = 3,
InitialDelay = TimeSpan.FromSeconds(10),
BackoffType = BackoffType.Exponential
};Per-Job Policies
Override retry behavior for specific job types:
csharp
options.RetryPolicies
.Register<SendEmailJob>(
maxRetries: 5,
delay: TimeSpan.FromSeconds(30),
backoffType: BackoffType.Exponential)
.Register<ImportJob>(
maxRetries: 10,
delay: TimeSpan.FromMinutes(2),
backoffType: BackoffType.Linear);Backoff Types
| Type | Description |
|---|---|
Fixed | Same delay between each retry |
Linear | Delay increases linearly (delay × attempt) |
Exponential | Delay doubles each attempt (delay × 2^attempt) |
Health Checks
Register health checks to monitor job infrastructure:
csharp
builder.Services.AddGrydJobsHealthChecks(
name: "grydjobs",
failureStatus: HealthStatus.Degraded,
tags: ["grydjobs", "background-jobs"]);The health check verifies:
- Background job servers are running
- Server heartbeats are recent (< 5 minutes)
Dashboard
The embedded Hangfire dashboard provides real-time monitoring:
csharp
app.UseGrydJobsDashboard(pathMatch: "/grydjobs/dashboard");Dashboard features:
- Real-time job processing stats
- Queue depths and throughput
- Recurring job schedules
- Failed job inspection
- Built-in retry from dashboard
Access requires authentication (integrated with ASP.NET Core Identity).