feat(comm): ack site health reports end-to-end (SiteHealthReportAck, additive contract)

This commit is contained in:
Joseph Doherty
2026-07-08 16:09:08 -04:00
parent f7b9d342e4
commit 17af376a8e
4 changed files with 105 additions and 3 deletions
@@ -0,0 +1,10 @@
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Health;
/// <summary>
/// Acknowledgement for a <see cref="SiteHealthReport"/> forwarded site→central.
/// Review 01 [Medium]: the transport was fire-and-forget, so the sender's
/// interval-counter restore logic could never observe a loss. The ack makes
/// delivery observable end-to-end (central processed the report).
/// </summary>
public sealed record SiteHealthReportAck(
string SiteId, long SequenceNumber, bool Accepted, string? Error = null);
@@ -394,6 +394,15 @@ public class CentralCommunicationActor : ReceiveActor
{
// No-op in non-clustered hosts (TestKit).
}
// Ack the site so its AkkaHealthReportTransport Ask completes and the
// report-loss counter-restore path can observe delivery (review 01
// [Medium]). Guarded so the peer-replica path (SiteHealthReportReplica,
// which arrives without an Ask sender) never dead-letters an ack.
if (!Sender.IsNobody())
{
Sender.Tell(new SiteHealthReportAck(report.SiteId, report.SequenceNumber, Accepted: true));
}
}
/// <summary>
@@ -390,11 +390,28 @@ public class SiteCommunicationActor : ReceiveActor, IWithTimers
// Internal: send heartbeat tick
Receive<SendHeartbeat>(_ => SendHeartbeatToCentral());
// Internal: forward health report to central
// Internal: forward health report to central. The original Sender (the
// AkkaHealthReportTransport's Ask) is forwarded as the ClusterClient.Send
// sender so the central SiteHealthReportAck routes straight back to the
// waiting Ask — making report delivery observable end-to-end (review 01
// [Medium]). Mirrors the NotificationSubmit ack pattern above.
Receive<SiteHealthReport>(msg =>
{
_centralClient?.Tell(
new ClusterClient.Send("/user/central-communication", msg), Self);
if (_centralClient == null)
{
// No ClusterClient registered yet. A non-accepted ack makes the
// sender's counter-restore path treat this tick as a loss.
_log.Warning(
"Cannot forward SiteHealthReport #{0} — no central ClusterClient registered",
msg.SequenceNumber);
Sender.Tell(new SiteHealthReportAck(
msg.SiteId, msg.SequenceNumber, Accepted: false,
Error: "Central ClusterClient not registered"));
return;
}
_centralClient.Tell(
new ClusterClient.Send("/user/central-communication", msg), Sender);
});
}