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

@@ -3,6 +3,7 @@ using Akka.Event;
using ScadaLink.Commons.Interfaces.Protocol;
using ScadaLink.Commons.Messages.DataConnection;
using ScadaLink.Commons.Types.Enums;
using ScadaLink.HealthMonitoring;
namespace ScadaLink.DataConnectionLayer.Actors;
@@ -28,6 +29,7 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
private readonly string _connectionName;
private readonly IDataConnection _adapter;
private readonly DataConnectionOptions _options;
private readonly ISiteHealthCollector _healthCollector;
public IStash Stash { get; set; } = null!;
public ITimerScheduler Timers { get; set; } = null!;
@@ -64,11 +66,13 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
string connectionName,
IDataConnection adapter,
DataConnectionOptions options,
ISiteHealthCollector healthCollector,
IDictionary<string, string>? connectionDetails = null)
{
_connectionName = connectionName;
_adapter = adapter;
_options = options;
_healthCollector = healthCollector;
_connectionDetails = connectionDetails ?? new Dictionary<string, string>();
}
@@ -96,6 +100,7 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
private void BecomeConnecting()
{
_log.Info("[{0}] Entering Connecting state", _connectionName);
_healthCollector.UpdateConnectionHealth(_connectionName, ConnectionHealth.Connecting);
Become(Connecting);
Self.Tell(new AttemptConnect());
}
@@ -129,6 +134,8 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
private void BecomeConnected()
{
_log.Info("[{0}] Entering Connected state", _connectionName);
_healthCollector.UpdateConnectionHealth(_connectionName, ConnectionHealth.Connected);
_healthCollector.UpdateTagResolution(_connectionName, _totalSubscribed, _resolvedTags);
Become(Connected);
Stash.UnstashAll();
}
@@ -166,6 +173,7 @@ public class DataConnectionActor : UntypedActor, IWithStash, IWithTimers
private void BecomeReconnecting()
{
_log.Warning("[{0}] Entering Reconnecting state", _connectionName);
_healthCollector.UpdateConnectionHealth(_connectionName, ConnectionHealth.Disconnected);
Become(Reconnecting);
// WP-9: Push bad quality for all subscribed tags on disconnect