Table of Contents

Class RuntimeWorkerPokeService

Namespace
Virtufin.WorkManager.Services
Assembly
Virtufin.WorkManager.dll

Periodically pokes the Runtime actor of every worker whose persisted status is running, so a worker that has gone quiet never ends up permanently deaf.

A Runtime worker's topic subscriptions are (re)created only by StartAsync or the actor's OnActivateAsync self-heal, and a Dapr actor activates only when something invokes it. A running worker with no inbound traffic gets no invocation: after a Runtime pod restart (its subscriptions are gone) or past the Runtime's 24h ActorIdleTimeout it would stay unsubscribed forever.

A live actor gets a cheap Touch (resetting its idle timer and making sure the worker is started, so a worker whose lease lapsed claims again); a deactivated one reactivates, and its self-heal reloads the code, claims the lease, starts the worker and resubscribes. The gap is bounded by IntervalSecondsEnvVar (default 60 s, floored at 30 s).

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

workManager WorkManager
actorProxies IActorProxyFactory
logger ILogger<RuntimeWorkerPokeService>

Fields

IntervalSecondsEnvVar

public const string IntervalSecondsEnvVar = "RUNTIME_WORKER_POKE_INTERVAL_SECONDS"

Field Value

string

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

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.

PokeOnceAsync(CancellationToken)

One pass over the running workers; never throws for a failed poke.

public Task PokeOnceAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task