fix: wire DCL connection state changes into ISiteHealthCollector
DataConnectionActor now calls UpdateConnectionHealth() on state transitions (Connecting/Connected/Reconnecting) and UpdateTagResolution() on connection establishment. DataConnectionManagerActor calls RemoveConnection() on actor removal. Health reports now include data connection statuses when instances are deployed with bindings.
This commit is contained in:
@@ -2,6 +2,7 @@ using Akka.Actor;
|
||||
using Akka.Event;
|
||||
using ScadaLink.Commons.Interfaces.Protocol;
|
||||
using ScadaLink.Commons.Messages.DataConnection;
|
||||
using ScadaLink.HealthMonitoring;
|
||||
|
||||
namespace ScadaLink.DataConnectionLayer.Actors;
|
||||
|
||||
@@ -15,14 +16,17 @@ public class DataConnectionManagerActor : ReceiveActor
|
||||
private readonly ILoggingAdapter _log = Context.GetLogger();
|
||||
private readonly IDataConnectionFactory _factory;
|
||||
private readonly DataConnectionOptions _options;
|
||||
private readonly ISiteHealthCollector _healthCollector;
|
||||
private readonly Dictionary<string, IActorRef> _connectionActors = new();
|
||||
|
||||
public DataConnectionManagerActor(
|
||||
IDataConnectionFactory factory,
|
||||
DataConnectionOptions options)
|
||||
DataConnectionOptions options,
|
||||
ISiteHealthCollector healthCollector)
|
||||
{
|
||||
_factory = factory;
|
||||
_options = options;
|
||||
_healthCollector = healthCollector;
|
||||
|
||||
Receive<CreateConnectionCommand>(HandleCreateConnection);
|
||||
Receive<SubscribeTagsRequest>(HandleRoute);
|
||||
@@ -44,7 +48,7 @@ public class DataConnectionManagerActor : ReceiveActor
|
||||
var adapter = _factory.Create(command.ProtocolType, command.ConnectionDetails);
|
||||
|
||||
var props = Props.Create(() => new DataConnectionActor(
|
||||
command.ConnectionName, adapter, _options, command.ConnectionDetails));
|
||||
command.ConnectionName, adapter, _options, _healthCollector, command.ConnectionDetails));
|
||||
|
||||
// Sanitize name for Akka actor path (replace spaces and invalid chars)
|
||||
var actorName = new string(command.ConnectionName
|
||||
@@ -97,6 +101,7 @@ public class DataConnectionManagerActor : ReceiveActor
|
||||
{
|
||||
Context.Stop(actor);
|
||||
_connectionActors.Remove(command.ConnectionName);
|
||||
_healthCollector.RemoveConnection(command.ConnectionName);
|
||||
_log.Info("Removed DataConnectionActor for {0}", command.ConnectionName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user