Class RuntimeWorkerPokeService
- Namespace
- Virtufin.WorkManager.Services
- Assembly
- Virtufin.WorkManager.dll
Periodically pokes the Runtime actor of every Runtime-routed worker whose persisted status is running, so a worker that has gone quiet never ends up permanently deaf (issue #47).
Runtime topic subscriptions live in the Runtime service's in-process
RuntimeTopicSubscriptionPool and are (re)created only by
StartAsync or the actor's OnActivateAsync self-heal -- and a
Dapr actor activates only when something invokes it. For a Running worker
with no inbound traffic, nothing ever does: no subscription -> no
messages -> no invocations -> no reactivation. Two failure modes fall out
of that: a Runtime pod restart (every subscription it hosted is gone; the
gateway's own recovery deliberately doesn't touch Runtime workers since
0.16.1, and WorkerHeartbeatService only touches
locally-registered workers, which Runtime-routed ones never are), and a
quiet worker exceeding the Runtime's 24h ActorIdleTimeout.
A live actor gets a cheap no-op Touch (and its idle timer resets); a deactivated one reactivates -> the self-heal reloads code and resubscribes its topics if the Runtime record says Running -- the exact tested path that already exists. The gap between "worker stops receiving" and "worker receives again" is therefore bounded by this interval instead of being unbounded. Interval comes from IntervalSecondsEnvVar (default 10 min, floored at 30s -- comfortably under the 24h idle timeout even at the floor).
public sealed class RuntimeWorkerPokeService : BackgroundService, IHostedService, IDisposable
- Inheritance
-
RuntimeWorkerPokeService
- Implements
- Inherited Members
Constructors
RuntimeWorkerPokeService(WorkManager, IActorProxyFactory, ILogger<RuntimeWorkerPokeService>)
public RuntimeWorkerPokeService(WorkManager workManager, IActorProxyFactory actorProxies, ILogger<RuntimeWorkerPokeService> logger)
Parameters
workManagerWorkManageractorProxiesIActorProxyFactoryloggerILogger<RuntimeWorkerPokeService>
Fields
IntervalSecondsEnvVar
public const string IntervalSecondsEnvVar = "RUNTIME_WORKER_POKE_INTERVAL_SECONDS"
Field Value
Methods
ExecuteAsync(CancellationToken)
This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationTokenTriggered when StopAsync(CancellationToken) is called.
Returns
Remarks
See Worker Services in .NET for implementation guidelines.