Skip to content
Advanced Topics

Advanced Topics

Production tuning for Simple Durable Jobs. These pages cover the knobs you reach for once jobs are flowing and you’re hardening for scale and failure.

Guarantees & Production Readiness
The honest contract: at-least-once execution, the idempotency requirement, backend support tiers, crash-recovery tuning, and how the guarantees are verified.
Production Operations
Deployment topology, fleet-safe migrations, graceful drain, health probes, sdj CLI, throughput tuning, metrics, DLQ, and retention runbooks.
Stale Lock Reaper
How the worker reclaims jobs whose owners crashed or disappeared, and the two options (WithStaleLockInterval, WithStaleLockAge) that tune it.
Pool Configuration
The four connection-pool presets, what each optimizes for, and how to hand-roll a custom PoolConfig with the option functions.
Storage Retry
Why the worker has two retry knobs (WithStorageRetry, WithDequeueRetry), what each protects against, and tuning for slow storage.
Job Retry Backoff
Configure worker-default and per-handler retry delays with BackoffPolicy, ExponentialBackoff, and jitter.
Dead-Letter Queue
List, count, inspect, and requeue jobs that exhausted retries, with explicit DLQ metadata and retention caveats.
Batch Enqueue
Use Batch entries and Queue.EnqueueBatch to insert many producer jobs with one storage batch operation.
Workflow Versioning
Use GetVersion markers to evolve Call, fan-out, and signal-wait sequences while in-flight runs keep their recorded branch.
Durable Timers
Pause workflows with Sleep and SleepUntil without holding a worker slot, with checkpointed deadlines that survive restart.
Batch Dequeue
Opt in to bounded worker-side batch dequeue to claim multiple due jobs per poll when storage supports it.
Transactional Checkpoints
Commit a phase checkpoint in the same GORM transaction as the business effect it protects.
Transactional Enqueue
Persist jobs inside your own GORM transaction so business rows and jobs commit or roll back together.
Payload Codec
Encrypt or transform job arguments, results, checkpoints, signal payloads, and error text (last_error / dead_letter_reason) at the GORM storage boundary.
Dashboard Authorization
Add optional per-action authorization for mutating dashboard RPCs while keeping identity extraction in your own middleware.
Execution Middleware
Wrap handler execution with interceptors for logging, auth context, panic classification, and error mapping.
Concurrency Caps
Cap parallelism fleet-wide and per-key (e.g. at most N jobs per customer) with DB-coordinated concurrency slots.
Rate Limiting
Throttle execution to a requests-per-window ceiling with per-queue token buckets and an optional fleet-wide limiter — without burning retry attempts.
Retention & GC
Automatically prune terminal jobs by per-status age window with a background retention worker, so the jobs table stays bounded.
Metrics
Export Prometheus / OpenTelemetry metrics — queue depth, throughput, wait/run latency, attempts, failures, retries — via an opt-in instrument.
Cancel & Terminate
Cancel a running job fleet-wide via a first-class verb across the facade, Connect-RPC, and the dashboard (cooperative cancellation).
Testing Utilities
The jobstest package: isolated SQLite fixtures and rivertest-style enqueue assertions for testing job producers and consumers.