EnvelopeFlow.Hosting.Worker 0.1.0-alpha.3.1

This is a prerelease version of EnvelopeFlow.Hosting.Worker.
dotnet add package EnvelopeFlow.Hosting.Worker --version 0.1.0-alpha.3.1
                    
NuGet\Install-Package EnvelopeFlow.Hosting.Worker -Version 0.1.0-alpha.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EnvelopeFlow.Hosting.Worker" Version="0.1.0-alpha.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EnvelopeFlow.Hosting.Worker" Version="0.1.0-alpha.3.1" />
                    
Directory.Packages.props
<PackageReference Include="EnvelopeFlow.Hosting.Worker" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EnvelopeFlow.Hosting.Worker --version 0.1.0-alpha.3.1
                    
#r "nuget: EnvelopeFlow.Hosting.Worker, 0.1.0-alpha.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EnvelopeFlow.Hosting.Worker@0.1.0-alpha.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EnvelopeFlow.Hosting.Worker&version=0.1.0-alpha.3.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=EnvelopeFlow.Hosting.Worker&version=0.1.0-alpha.3.1&prerelease
                    
Install as a Cake Tool

Optional worker

The development partition coordinator preserves exclusive ownership through synchronous lease-loss callback reentry. Every termination removes only its own exact mapping before cancellation callbacks run, freeing capacity even when renewal observes expiry before a delayed timer. A replacement acquired by a callback remains authoritative and cannot be overwritten by the outer acquisition or removed by a stale lease. Delivery-store fences still provide submission authority.

Dynamic discovery is opt-in through new DeliveryWorker(scopeSource, dispatcher, ...), with IWorkerScopeSource owned by the application. Each refresh supplies a complete snapshot of zero to 1,000 scopes (or a smaller MaximumScopes); the worker copies it and rejects null, duplicate or oversized snapshots as a whole. It never truncates scope discovery. The independent refresh loop runs every minute by default, with a ten-second worker-owned callback deadline. Refresh failure/timeout removes the previous snapshot and cancels scope work until a valid refresh succeeds. A noncooperative source cannot accumulate another outstanding discovery task on every refresh, and a late result cannot restore the expired snapshot. Refresh intervals are 100 ms–one day; callback deadlines are 100 ms–30 seconds and at most one third of the partition lease duration. Dynamic sweeps visit every current scope sequentially and rotate the first scope each sweep. Source removal cancels the scope's cooperative operation token, even while a dispatcher call is pending.

Optional IWorkerPartitionCoordinator grants full-scope advisory scheduling leases to the supplied workerId. The worker validates scope/owner/generation, retains ownership across polls, renews every third lease duration and cancels scope work on loss, renewal refusal/timeout, removal or shutdown completion. Acquire/renew/release callbacks have worker-owned deadlines. Grants need a cancellable Lost token; an invalid binding never authorizes a store claim. Coordinators must atomically compare full scope, owner and generation, refuse renewal after expiry, signal loss before reassignment, and make stale release harmless. InMemoryWorkerPartitionCoordinator is a bounded development-only, process-local reference. Applications select a distributed coordinator appropriate to their deployment; this hosting package has no PostgreSQL coupling. These leases coordinate scheduling; delivery-store claim/submission fences remain the submission authority. Losing ownership cannot retract provider I/O already begun or remove network-partition uncertainty. A provider ignoring cancellation may outlive the lease, as it may outlive shutdown; uncertain delivery remains subject to the durable store's recovery rules.

Health returns an immutable aggregate snapshot containing status, discovered/owned scope counts, completed-operation/sweep counts, consecutive store failures and refresh/sweep times. Observations add fixed discovery/partition event codes and counts. Neither surface contains tenant/scope/owner identifiers, exception text, addresses, credentials or payloads. Snapshots describe this worker's process state and do not assert database or provider health.

The manager holds at most MaximumScopes coordination lifetimes across active and retired assignments. An acquisition/renewal/disposal callback that ignores its deadline continues consuming that shared budget until it actually completes and any returned lease is disposed. Scope removal/re-addition cannot reset this history or accumulate callbacks; saturated capacity suppresses new acquisitions. Late successful grants are disposed without authorizing work. A permanently noncooperative coordinator can therefore leave coordination unavailable until it is repaired or the worker restarts. Health progress observations cannot restore Running after Draining, Faulted or Stopped begins.

DeliveryWorker polls an application-selected dispatcher and copied list of 1–1000 scopes. Applications retain their data sources, endpoints, admission services, transports and deployment controls. The worker never initializes or migrates a schema. The existing constructor parameters remain compatible; optional recovery options, failure classification, safe observation and an optional application event handler are additional named parameters.

After a sweep submits deliveries or acknowledges outbox events, the worker immediately starts another sweep after a cooperative yield. Each sweep visits every selected scope before returning to the first. Empty sweeps back off from 10 milliseconds (or the shorter configured interval), doubling up to pollInterval (one second by default). Work and reconnection reset this idle delay. The configured interval remains the maximum idle wait; store latency, scope sweeps and scheduler delays also affect detection time. Short probes after a burst improve responsiveness and add a bounded number of empty polls before settling at that ceiling. No global ThreadPool settings or dispatcher batch limits change.

Poll intervals must be one millisecond through one day. Reconnect delays and the shutdown drain deadline must be one millisecond through five minutes. Submillisecond values are rejected because the runtime rounds those positive delays down to zero, which would turn empty sweeps or transient-failure recovery into immediate loops.

IWorkerFailureClassifier must explicitly recognize transient store failures. With no classifier, failures are not retried. Treat connection interruption and declared recoverable database states separately from authentication, missing schema, incompatible payloads, configuration failures and provider outcomes. A host using Npgsql can classify its own store exceptions without adding PostgreSQL to this hosting package. Rich decision evaluators and transports already have their own fail-closed/uncertain behavior; do not relabel arbitrary application exceptions as database outages.

Reconnect uses bounded exponential delays (one second initially, thirty seconds maximum) and terminates on the configured consecutive-failure count (ten by default). Successful polling resets the count. Cancellation interrupts polling/backoff immediately. A retry invokes the dispatcher again through its fenced durable store; it does not directly repeat a provider send. Submitting lease recovery remains Unknown, and Accepted/Unknown work is not automatically resubmitted. An optional IDeliveryEventHandler polls the existing outbox after delivery work, retaining its at-least-once application contract.

Shutdown prevents the next claim and permits the already claimed batch to drain until ShutdownDrainTimeout (thirty seconds by default). At that deadline the operation token is cancelled; a possible provider send remains uncertain and the dispatcher attempts to preserve its completion evidence. StopAsync also bounds waiting, independently from the host's cancellation deadline. A provider ignoring cancellation can outlive StopAsync; the worker reports DrainIncomplete, does not start another send, and operators must inspect durable state after process exit. Applications should configure their host shutdown timeout to accommodate this drain and require transports/store calls to observe cancellation. Abrupt process termination remains a separate fault scenario.

IWorkerObserver receives fixed event codes, failure counts and delays only. It receives no exception, scope, destination, token, body or credential. Observers must be nonblocking; exceptions are ignored so telemetry cannot turn successful persistence into retries. Persistent failure/retry exhaustion surfaces as a fixed WorkerRecoveryException without a raw inner exception. Application diagnostics may classify the original exception but must redact its sensitive details. Monitor disconnected/reconnected, retry-limit and incomplete-drain codes, then inspect queues/outbox before any explicit replay of uncertain work.

Focused tests use a manual clock and application-owned stores to verify delay bounds, cancellation, recovery, sanitization, graceful completion and cooperative/noncooperative drain deadlines. Separate-process/database drills provide their own opt-in evidence; a clock-controlled unit test does not certify database failover or production capacity.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha.3.1 45 11/22/2026
0.1.0-alpha.2.1 71 11/9/2026