feat(mesh-phase5): tap the 4 telemetry publish seams into the local hub (DPS intact)
Each of the four telemetry publish seams now also emits its DPS payload into the node-local ITelemetryLocalHub (Phase 5), leaving the existing DistributedPubSub publish untouched: - driver-health AkkaDriverHealthPublisher -> TelemetryItem.Health - resilience DriverResilienceStatusPublisherService -> TelemetryItem.Resilience - alerts ScriptedAlarmHostActor + DriverHostActor (native) -> TelemetryItem.Alarm - script-logs VirtualTagActor + DpsScriptLogPublisher -> TelemetryItem.Script DI services take the hub as a required ctor param; actors take an optional nullable hub threaded through their Props and the real spawn sites (DriverHostActor <- ServiceCollectionExtensions; VirtualTagActor/ScriptedAlarmHostActor <- DriverHostActor), so existing test Props constructions keep compiling and simply do not emit. The hub is a no-op until a gRPC client subscribes, so the emit is safe on every node. Claude-Session: https://claude.ai/code/session_01GASWkNEi68FSCtvr6rLoEW
This commit is contained in:
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Drivers;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Resilience;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Telemetry;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Host.Drivers;
|
||||
|
||||
@@ -23,22 +24,26 @@ public sealed class DriverResilienceStatusPublisherService : BackgroundService
|
||||
private readonly DriverResilienceStatusTracker _tracker;
|
||||
private readonly Func<ActorSystem> _actorSystemAccessor;
|
||||
private readonly ILogger<DriverResilienceStatusPublisherService> _logger;
|
||||
private readonly ITelemetryLocalHub _hub;
|
||||
private readonly TimeSpan _interval;
|
||||
|
||||
/// <summary>Initializes a new instance of <see cref="DriverResilienceStatusPublisherService"/>.</summary>
|
||||
/// <param name="tracker">The process-singleton resilience-status tracker to read each tick.</param>
|
||||
/// <param name="actorSystemAccessor">Lazy accessor for the Akka <see cref="ActorSystem"/> whose DPS mediator publishes the snapshots.</param>
|
||||
/// <param name="logger">Logger for publish diagnostics.</param>
|
||||
/// <param name="hub">The node-local live-telemetry hub each published snapshot is also emitted into (Phase 5).</param>
|
||||
/// <param name="interval">Publish cadence; defaults to 5 s when null.</param>
|
||||
public DriverResilienceStatusPublisherService(
|
||||
DriverResilienceStatusTracker tracker,
|
||||
Func<ActorSystem> actorSystemAccessor,
|
||||
ILogger<DriverResilienceStatusPublisherService> logger,
|
||||
ITelemetryLocalHub hub,
|
||||
TimeSpan? interval = null)
|
||||
{
|
||||
_tracker = tracker;
|
||||
_actorSystemAccessor = actorSystemAccessor;
|
||||
_logger = logger;
|
||||
_hub = hub;
|
||||
_interval = interval ?? DefaultInterval;
|
||||
}
|
||||
|
||||
@@ -77,7 +82,12 @@ public sealed class DriverResilienceStatusPublisherService : BackgroundService
|
||||
|
||||
var mediator = DistributedPubSub.Get(_actorSystemAccessor()).Mediator;
|
||||
foreach (var message in messages)
|
||||
{
|
||||
mediator.Tell(new Publish(DriverResilienceStatusChanged.TopicName, message));
|
||||
// Phase 5: fan the same snapshot into the node-local live-telemetry hub (no-op until a
|
||||
// gRPC client subscribes). The DPS publish above is unchanged — a strictly additive tap.
|
||||
_hub.Emit(new TelemetryItem.Resilience(message));
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user