Namespace Virtufin.WorkManager.Services
Classes
- ApiLifecyclePublisher
Publishes worker lifecycle events to the virtufin-api's
system-eventstopic. Events are CloudEvents v1.0 envelopes with the WorkManager's URN as the source. The publisher is best-effort: failures are logged but never propagated, so an unreachable API does not break the WorkManager's worker state machine.
- AppMetrics
Application-level metrics for the WorkManager service.
- DaprCircuitBreakerHealthCheck
Health check that reports Dapr circuit breaker state.
- DaprResiliencePipeline
Provides resilience policies for Dapr operations with retry and circuit breaker. Constants are configurable via DaprResilienceOptions (env-var-driven).
- DotNetDllBridgeWarmupHealthCheck
Health check that verifies the DotNetDll engine's CoreCLR bridge warmup has completed, so a pod is not reported Ready until the one-time, potentially tens-of-seconds-long bridge bootstrap is off the request path (see HostFxrBootstrap).
- DotNetDllBridgeWarmupHostedService
Hosted service that eagerly warms up the DotNetDll engine's CoreCLR bridge on startup (Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.EnsureInitialized()), so the one-time bootstrap cost is paid before this pod is reported Ready rather than on a live worker's
CreateWorkercall.Why this matters: under NativeAOT, loading a JIT-compiled worker DLL requires bootstrapping a secondary CoreCLR runtime via
libhostfxrthe first time any pod does this in its process lifetime. That cost has been observed live to take tens of seconds -- far longer than Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap's own documented ~200-500ms expectation -- comfortably busting the API Gateway's flat, 30-second deadline on forwarded dynamic-dispatch calls. Paying this cost during startup instead removes it from the request path entirely.Kestrel readiness is gated via DotNetDllBridgeWarmupHealthCheck:
Unhealthywhile warmup is in progress,Healthyonce it completes (whether it succeeded or failed -- see FailWarmup(Exception)).
- DotNetDllBridgeWarmupState
Tracks whether the DotNetDll engine's CoreCLR bridge has been warmed up (or an eager warm-up was attempted and failed) on startup. Used by the bridge warmup health check to gate Kestrel readiness.
- HostFxrDotNetDllBridgeWarmup
Thin seam around Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.EnsureInitialized() so DotNetDllBridgeWarmupHostedService's success/failure handling is unit-testable -- the real bootstrap always succeeds as a fast no-op in a JIT test host (Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.IsCoreClrLoaded() is true there), so a test double is needed to exercise the failure path.
- RecoveryHealthCheck
Health check that verifies worker recovery has completed successfully.
- RecoveryState
Tracks the state of worker recovery on startup. Used by the recovery health check to gate Kestrel readiness.
- ResilientDaprPublisher
Buffers outbound pub/sub messages during Dapr outages and flushes on reconnect.
- WorkManagerRecoveryHostedService
Hosted service that automatically recovers workers on application startup, gated by Enabled and coordinated across multiple WorkManager instances via RecoveryLeaderElector.
When multiple instances start concurrently, only the leader performs recovery — the others wait for the leader lease to expire (or be released) before they would attempt to take over. This avoids the N×W engine-load waste described in WM #4.
Kestrel readiness is gated via RecoveryHealthCheck (mapped on the
/readyendpoint, not/health-- see Program.cs):Unhealthywhile recovery is in progress, or if it failed.Healthyonce recovery completes (whether this instance performed it or another leader did).
- WorkerProcessingRetryPipeline
Polly-based retry pipeline for worker business-logic processing failures, as distinct from DaprResiliencePipeline (which wraps Dapr/Gateway infra calls). Exhausting all attempts lets the caller's exception propagate so it can dead-letter the message -- see WorkerProcessingRetryOptions for why this exists as its own pipeline.
Interfaces
- IDotNetDllBridgeWarmup
Thin seam around Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.EnsureInitialized() so DotNetDllBridgeWarmupHostedService's success/failure handling is unit-testable -- the real bootstrap always succeeds as a fast no-op in a JIT test host (Virtufin.WorkManager.Engine.DotNetDll.HostFxrBootstrap.IsCoreClrLoaded() is true there), so a test double is needed to exercise the failure path.
- IWorkerRecoveryExecutor
Abstraction over the WorkManager's recovery entry point. Allows the hosted service to be unit-tested without mocking the sealed
WorkManagerclass.