Skip to content

Configuration

Everything is configured through AddPgWorkflows(pg => ...) on your service collection.

builder.Services.AddPgWorkflows(pg =>
pg.UsePostgres(connectionString)
.ConfigureWorkflowWorker(options => options with { /* ... */ })
.ConfigureActivityWorker(options => options with { /* ... */ })
.AddWorkflow<TrialOnboardingWorkflow>()
.AddActivities<EmailActivities>()
);
MethodPurpose
UsePostgres(connectionString, ensureSchemaOnStart = true)Point PgWorkflows at your database. Creates the schema on startup by default.
DisableWorkers()Client-only mode: the process can start, signal, and await workflows but runs no background workers. See workers & scaling.
ConfigureWorkflowWorker(options => ...)Tune the workflow worker (see below).
ConfigureActivityWorker(options => ...)Tune the activity worker (see below).
AddWorkflow<TWorkflow>()Register a workflow class.
AddActivities<TActivities>()Register an activity class (all [Activity] methods).
RegisterActivity<TInput, TOutput>(...)Register a single delegate-based activity.
OptionDefaultDescription
WorkerIdmachine nameIdentifies this worker in leases.
BatchSize16Max runs leased per poll.
MaxConcurrencyprocessor countMax runs executed concurrently.
LeaseDuration30 sHow long a lease lives between heartbeats.
PollInterval250 msHow often an idle worker polls for work.
ParkGrace30 sSafety-net deadline for runs parked on activity steps; they’re normally woken sooner by the edge-trigger.
MaxAttempts1Workflow-level attempts.
GetRetryDelaymin(attempt × 5 s, 60 s)Backoff between attempts.
OptionDefaultDescription
WorkerIdmachine nameIdentifies this worker in leases.
BatchSize16Max jobs leased per poll; only effective below MaxConcurrency.
MaxConcurrencyprocessor count × 4Max activities executed concurrently. Lower it for CPU-bound work.
LeaseDuration30 sHow long a lease lives between heartbeats.
PollInterval250 msHow often an idle worker polls for work.
GetRetryDelaymin(attempt × 5 s, 60 s)Backoff between activity retry attempts.