Table of Contents

Class WorkerRecoveryOptions

Namespace
Virtufin.WorkManager.Configuration
Assembly
Virtufin.WorkManager.dll

Worker recovery tuning. Controls whether WorkManagerRecoveryHostedService runs on startup and how it elects a leader when multiple WorkManager instances start concurrently.

public sealed record WorkerRecoveryOptions : IEquatable<WorkerRecoveryOptions>
Inheritance
WorkerRecoveryOptions
Implements
Inherited Members

Fields

AcquireTimeoutSecondsEnvVar

Env var for how long to wait for the leader lease before giving up.

public const string AcquireTimeoutSecondsEnvVar = "WORKER_RECOVERY_ACQUIRE_TIMEOUT_SECONDS"

Field Value

string

ConnectivityTimeoutSecondsEnvVar

Env var for how long to keep retrying while the state store is unreachable (e.g. sidecar still starting).

public const string ConnectivityTimeoutSecondsEnvVar = "WORKER_RECOVERY_CONNECTIVITY_TIMEOUT_SECONDS"

Field Value

string

DefaultAcquireTimeoutSeconds

Default acquire timeout (30s — bounds how long we wait for a live competing lease to expire once the store is reachable).

public const int DefaultAcquireTimeoutSeconds = 30

Field Value

int

DefaultConnectivityTimeoutSeconds

Default connectivity timeout (120s). Covers cold-start races where the state-store sidecar (e.g. Dapr) isn't yet accepting connections when this instance starts — observed in production as a burst of "Connection refused" errors that outlasted the old fixed 30s AcquireTimeoutSeconds window, permanently skipping recovery for that instance's lifetime.

public const int DefaultConnectivityTimeoutSeconds = 120

Field Value

int

DefaultEnabled

Default: recovery is enabled.

public const bool DefaultEnabled = true

Field Value

bool

DefaultLeaseTtlSeconds

Default lease TTL (5 minutes — long enough for typical recovery, short enough to release on crash).

public const int DefaultLeaseTtlSeconds = 300

Field Value

int

EnabledEnvVar

Env var that gates whether recovery runs at all on startup.

public const string EnabledEnvVar = "WORKER_RECOVERY_ON_START"

Field Value

string

LeaseTtlSecondsEnvVar

Env var for the lease TTL in seconds when this instance wins the leader election.

public const string LeaseTtlSecondsEnvVar = "WORKER_RECOVERY_LEASE_TTL_SECONDS"

Field Value

string

Properties

AcquireTimeoutSeconds

How long this instance will wait to acquire the lease before skipping recovery, once the state store is reachable.

public int AcquireTimeoutSeconds { get; init; }

Property Value

int

ConnectivityTimeoutSeconds

How long this instance will keep retrying, with backoff, while it cannot reach the state store at all.

public int ConnectivityTimeoutSeconds { get; init; }

Property Value

int

Enabled

Whether recovery runs on startup at all.

public bool Enabled { get; init; }

Property Value

bool

LeaseTtlSeconds

How long the leader lease is held before another instance may take over.

public int LeaseTtlSeconds { get; init; }

Property Value

int

Methods

FromEnvironment(Func<string, string?>)

Reads options from the supplied environment-variable provider. Falls back to defaults when keys are absent or malformed.

public static WorkerRecoveryOptions FromEnvironment(Func<string, string?> getEnvironment)

Parameters

getEnvironment Func<string, string>

Returns

WorkerRecoveryOptions