feat(runtime): publish DriverHealthChanged via DriverInstanceActor
- IDriverHealthPublisher in Core.Abstractions + NullDriverHealthPublisher no-op for tests/dev-stub paths. - AkkaDriverHealthPublisher in Runtime forwards to the cluster-wide `driver-health` DPS topic. - DriverInstanceActor instrumented to publish snapshots on every observable state change + a periodic 30s heartbeat so the AdminUI snapshot store warms up for newly-joined SignalR clients. - Sliding 5-minute Faulted-count tracked per actor via Queue<DateTime>. - DriverHostActor.SpawnChild threads clusterId (_localNode.Value) and the health publisher down to every DriverInstanceActor child. - ServiceCollectionExtensions.AddOtOpcUaRuntime registers AkkaDriverHealthPublisher as IDriverHealthPublisher singleton.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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>
|
||||
void Publish(
|
||||
string clusterId,
|
||||
string driverInstanceId,
|
||||
DriverHealth health,
|
||||
int errorCount5Min);
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{ /* no-op */ }
|
||||
}
|
||||
Reference in New Issue
Block a user