refactor: remove ClusterClient streaming path (DebugStreamEvent), events flow via gRPC
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
namespace ScadaLink.Commons.Messages.DebugView;
|
||||
|
||||
/// <summary>
|
||||
/// Wraps a debug stream event (AttributeValueChanged or AlarmStateChanged) with
|
||||
/// the correlationId for routing back to the correct DebugStreamBridgeActor on central.
|
||||
/// Sent from InstanceActor → SiteCommunicationActor → ClusterClient → CentralCommunicationActor.
|
||||
/// </summary>
|
||||
public record DebugStreamEvent(string CorrelationId, object Event);
|
||||
@@ -86,8 +86,6 @@ public class CentralCommunicationActor : ReceiveActor
|
||||
// Route enveloped messages to sites
|
||||
Receive<SiteEnvelope>(HandleSiteEnvelope);
|
||||
|
||||
// Route debug stream events from sites to the correct bridge actor
|
||||
Receive<Commons.Messages.DebugView.DebugStreamEvent>(HandleDebugStreamEvent);
|
||||
}
|
||||
|
||||
private void HandleHeartbeat(HeartbeatMessage heartbeat)
|
||||
@@ -96,18 +94,6 @@ public class CentralCommunicationActor : ReceiveActor
|
||||
Context.Parent.Tell(heartbeat);
|
||||
}
|
||||
|
||||
private void HandleDebugStreamEvent(Commons.Messages.DebugView.DebugStreamEvent msg)
|
||||
{
|
||||
if (_debugSubscriptions.TryGetValue(msg.CorrelationId, out var entry))
|
||||
{
|
||||
entry.Subscriber.Tell(msg.Event);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Debug("No debug subscription found for correlationId {0}, dropping event", msg.CorrelationId);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSiteHealthReport(SiteHealthReport report)
|
||||
{
|
||||
var aggregator = _serviceProvider.GetService<ICentralHealthAggregator>();
|
||||
|
||||
@@ -146,12 +146,6 @@ public class SiteCommunicationActor : ReceiveActor, IWithTimers
|
||||
new ClusterClient.Send("/user/central-communication", msg), Self);
|
||||
});
|
||||
|
||||
// Internal: forward debug stream events to central (site→central streaming)
|
||||
Receive<DebugStreamEvent>(msg =>
|
||||
{
|
||||
_centralClient?.Tell(
|
||||
new ClusterClient.Send("/user/central-communication", msg), Self);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void PreStart()
|
||||
|
||||
@@ -50,10 +50,6 @@ public class InstanceActor : ReceiveActor
|
||||
private readonly Dictionary<string, IActorRef> _alarmActors = new();
|
||||
private FlattenedConfiguration? _configuration;
|
||||
|
||||
// WP-25: Debug view subscribers
|
||||
private readonly HashSet<string> _debugSubscriberCorrelationIds = new();
|
||||
private ActorSelection? _siteCommActor;
|
||||
|
||||
// DCL manager actor reference for subscribing to tag values
|
||||
private readonly IActorRef? _dclManager;
|
||||
// Maps tag paths back to attribute canonical names for DCL updates
|
||||
@@ -150,9 +146,6 @@ public class InstanceActor : ReceiveActor
|
||||
base.PreStart();
|
||||
_logger.LogInformation("InstanceActor started for {Instance}", _instanceUniqueName);
|
||||
|
||||
// Resolve SiteCommunicationActor for routing debug stream events back to central
|
||||
_siteCommActor = Context.ActorSelection("/user/site-communication");
|
||||
|
||||
// Asynchronously load static overrides from SQLite and pipe to self
|
||||
var self = Self;
|
||||
_storage.GetStaticOverridesAsync(_instanceUniqueName).ContinueWith(t =>
|
||||
@@ -370,12 +363,6 @@ public class InstanceActor : ReceiveActor
|
||||
|
||||
// WP-23: Publish to site-wide stream
|
||||
_streamManager?.PublishAlarmStateChanged(changed);
|
||||
|
||||
// Forward to debug subscribers via SiteCommunicationActor → ClusterClient → central
|
||||
foreach (var correlationId in _debugSubscriberCorrelationIds)
|
||||
{
|
||||
_siteCommActor?.Tell(new DebugStreamEvent(correlationId, changed));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -383,9 +370,6 @@ public class InstanceActor : ReceiveActor
|
||||
/// </summary>
|
||||
private void HandleSubscribeDebugView(SubscribeDebugViewRequest request)
|
||||
{
|
||||
var subscriptionId = request.CorrelationId;
|
||||
_debugSubscriberCorrelationIds.Add(subscriptionId);
|
||||
|
||||
// Build snapshot from current state
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var attributeValues = _attributes.Select(kvp => new AttributeValueChanged(
|
||||
@@ -412,8 +396,8 @@ public class InstanceActor : ReceiveActor
|
||||
Sender.Tell(snapshot);
|
||||
|
||||
_logger.LogDebug(
|
||||
"Debug view subscriber added for {Instance}, subscriptionId={Id}",
|
||||
_instanceUniqueName, subscriptionId);
|
||||
"Debug view snapshot sent for {Instance}, correlationId={Id}",
|
||||
_instanceUniqueName, request.CorrelationId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -421,10 +405,8 @@ public class InstanceActor : ReceiveActor
|
||||
/// </summary>
|
||||
private void HandleUnsubscribeDebugView(UnsubscribeDebugViewRequest request)
|
||||
{
|
||||
_debugSubscriberCorrelationIds.Remove(request.CorrelationId);
|
||||
|
||||
_logger.LogDebug(
|
||||
"Debug view subscriber removed for {Instance}, correlationId={Id}",
|
||||
"Debug view unsubscribe for {Instance}, correlationId={Id}",
|
||||
_instanceUniqueName, request.CorrelationId);
|
||||
}
|
||||
|
||||
@@ -478,12 +460,6 @@ public class InstanceActor : ReceiveActor
|
||||
{
|
||||
alarmActor.Tell(changed);
|
||||
}
|
||||
|
||||
// Forward to debug subscribers via SiteCommunicationActor → ClusterClient → central
|
||||
foreach (var correlationId in _debugSubscriberCorrelationIds)
|
||||
{
|
||||
_siteCommActor?.Tell(new DebugStreamEvent(correlationId, changed));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user