30d0697c28
`IHostConnectivityProbe` was a dead surface: eleven drivers implement it, `GetHostStatuses()` had ZERO production call sites, and `OnHostStatusChanged` had no subscriber outside the Galaxy driver's own aggregator. Per-host connectivity was computed by every driver and read by nobody. The issue offered "build the publisher or delete it". The publisher as its entity doc described it — driver nodes upserting `DriverHostStatus` rows — is not buildable: per-cluster mesh Phase 4 gates `AddOtOpcUaConfigDb` on the `admin` role, so a driver-only node has no ConfigDb connection to write rows with. So the capability is kept and the transport changed. `DriverHealthChanged.HostStatuses` now carries the probe result to `/hosts` as a Hosts column. That channel already reached the page, already survives the mesh split via the Phase 5 gRPC telemetry stream, and already replays a last-value snapshot on re-subscribe — so per-host state re-primes after a reconnect without a durable store. Both halves of the interface finally do what they are for: the event triggers a prompt publish, the pull is the source of truth. The point of the column is the case the driver-level state chip structurally cannot express: a multi-device driver stays aggregate-Healthy while ONE of its devices is unreachable. Two traps, both pinned by tests that were falsified against the prod code: - The host digest MUST be in the publish fingerprint. On a single-host-down transition every other fingerprint component is unchanged, so the dedup would swallow exactly the publish carrying the news — the trap that already bit the rediscovery signal. Removing it turns the guard test red, verified. - null (no probe) must stay distinct from empty (probe with no hosts). proto3 cannot tell an absent repeated field from an empty one, hence the explicit `has_host_statuses` flag; collapsing them would render every probe-less driver as one whose devices are all fine. Dropped: the DriverHostStatus entity, enum, DbSet, model config and table (migration DropDriverHostStatusTable — empty on every deployment, so the scaffolder's data-loss warning is moot, and Down() recreates it exactly). Found en route, NOT fixed here: `DriverInstanceResilienceStatus` is the identical defect — no writer, no reader, only a DbSet declaration, while the live data rides the `driver-resilience-status` telemetry channel. Its doc-comment now states that rather than describing the sampler and AdminUI join that were never built. Filed as #524 rather than widening this schema change beyond what was asked. Claude-Session: https://claude.ai/code/session_015p7wGqy3YpZNCpDzTpGMKo
63 lines
2.8 KiB
C#
63 lines
2.8 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
/// <summary>
|
|
/// Sink for driver-health state-change notifications. The runtime DI wires the
|
|
/// Akka-DistributedPubSub-backed implementation; tests and dev-stub paths use
|
|
/// <see cref="NullDriverHealthPublisher"/> to opt out without changing call sites.
|
|
/// </summary>
|
|
public interface IDriverHealthPublisher
|
|
{
|
|
/// <summary>
|
|
/// Publishes a health snapshot for one driver instance. Implementations must be
|
|
/// non-blocking and tolerant of being called from any thread.
|
|
/// </summary>
|
|
/// <param name="clusterId">The cluster the driver instance belongs to.</param>
|
|
/// <param name="driverInstanceId">The driver instance the snapshot describes.</param>
|
|
/// <param name="health">The current health snapshot.</param>
|
|
/// <param name="errorCount5Min">The number of errors observed in the trailing 5-minute window.</param>
|
|
/// <param name="rediscoveryNeededUtc">
|
|
/// When the driver last raised <see cref="IRediscoverable.OnRediscoveryNeeded"/>, or null if never
|
|
/// (or if it is not an <see cref="IRediscoverable"/>). Advisory: it prompts an operator to
|
|
/// re-browse, and never rebuilds the served address space.
|
|
/// </param>
|
|
/// <param name="rediscoveryReason">The driver-supplied reason from that event; null when
|
|
/// <paramref name="rediscoveryNeededUtc"/> is null.</param>
|
|
/// <param name="hostStatuses">
|
|
/// Per-host connectivity from <see cref="IHostConnectivityProbe.GetHostStatuses"/>, or null when the
|
|
/// driver is not an <see cref="IHostConnectivityProbe"/>. Lets a multi-device driver (a FOCAS or
|
|
/// AbLegacy instance owning several PLCs) surface ONE unreachable device that would otherwise be
|
|
/// invisible behind an aggregate-Healthy driver row.
|
|
/// </param>
|
|
void Publish(
|
|
string clusterId,
|
|
string driverInstanceId,
|
|
DriverHealth health,
|
|
int errorCount5Min,
|
|
DateTime? rediscoveryNeededUtc = null,
|
|
string? rediscoveryReason = null,
|
|
IReadOnlyList<HostConnectivityStatus>? hostStatuses = null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Drop-in no-op for tests and dev-stub paths. Production wires the Akka-backed
|
|
/// implementation in the Runtime project.
|
|
/// </summary>
|
|
public sealed class NullDriverHealthPublisher : IDriverHealthPublisher
|
|
{
|
|
/// <summary>Singleton instance.</summary>
|
|
public static readonly NullDriverHealthPublisher Instance = new();
|
|
|
|
private NullDriverHealthPublisher() { }
|
|
|
|
/// <inheritdoc />
|
|
public void Publish(
|
|
string clusterId,
|
|
string driverInstanceId,
|
|
DriverHealth health,
|
|
int errorCount5Min,
|
|
DateTime? rediscoveryNeededUtc = null,
|
|
string? rediscoveryReason = null,
|
|
IReadOnlyList<HostConnectivityStatus>? hostStatuses = null)
|
|
{ /* no-op */ }
|
|
}
|