Zum Hauptinhalt springen

HubRegistrationRecoveryService

Namespace: Meshmakers.Octo.Sdk.Common.Adapters

The restart decision shared by both kinds of adapter process: a process that was registered at the communication controller and stays unregistered for longer than AdapterOptions.HubRegistrationRecoveryTimeout stops its host so the container restarts.

public abstract class HubRegistrationRecoveryService : BackgroundService, IHostedService, IDisposable

Inheritance Object → BackgroundService → HubRegistrationRecoveryService
Implements IHostedService, IDisposable

Remarks:

A dedicated adapter registers at the tenant's adapter hub (AdapterHubRecoveryService, AB#5409); an adapter pool member registers at the tenant-free adapter pool hub (AdapterPoolHubRecoveryService, AB#4924 AP-I5). The two differ only in which connection they sample — the decision, its two guards and its configuration are one policy, so they live here once.

Two guards keep this from turning into a restart loop:

It only arms after IAdapterHubRegistrationState.HasEverRegistered. A process that never registered may be waiting for a tenant that is not enabled yet, or for a controller that was never deployed — restarting that in a loop repairs nothing and hides the real cause.

The timeout is generous (15 minutes by default, far beyond any reconnect the SignalR client performs by itself) and can be disabled outright with AdapterOptions.HubRegistrationRecoveryEnabled.

🔴 It stops the host by decision only, never by a failing check (AB#5473): an exception escaping would stop the host as well, on the spot instead of after the timeout. A connection state that cannot be read therefore counts as "not alive".

Properties​

ExecuteTask​

public Task ExecuteTask { get; }

Property Value​

Task

Methods​

ExecuteAsync(CancellationToken)​

protected Task ExecuteAsync(CancellationToken stoppingToken)

Parameters​

stoppingToken CancellationToken

Returns​

Task

Evaluate(DateTime)​

Advances the outage tracking and reports whether the process must be restarted. Internal so the decision can be tested without a timer.

internal bool Evaluate(DateTime utcNow)

Parameters​

utcNow DateTime

Returns​

Boolean