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:
Joseph Doherty
2026-03-18 00:20:02 -04:00
parent 4f22ca2b1f
commit 75a6636a2c
6 changed files with 28 additions and 7 deletions

View File

@@ -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);
}
}