feat(commons): add deploy/admin/audit/redundancy/fleet message contracts

This commit is contained in:
Joseph Doherty
2026-05-26 04:27:18 -04:00
parent fee4a8c008
commit 5d3a5a40d7
10 changed files with 154 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin;
/// <summary>
/// Request from the admin UI to the <c>AdminOperationsActor</c> singleton asking it to snapshot
/// the current live-edit state and start a deployment.
/// </summary>
public sealed record StartDeployment(
string CreatedBy,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,23 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin;
public enum StartDeploymentOutcome
{
Accepted,
NoChanges,
AnotherDeploymentInFlight,
Rejected,
}
/// <summary>
/// Reply from the <c>AdminOperationsActor</c> singleton. <c>Accepted</c> means the snapshot
/// was sealed and a <c>Deployment</c> row was created; the in-flight deployment can be
/// tracked through fleet-status broadcasts.
/// </summary>
public sealed record StartDeploymentResult(
StartDeploymentOutcome Outcome,
DeploymentId? DeploymentId,
RevisionHash? RevisionHash,
string? Message,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,17 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Audit;
/// <summary>
/// Cluster-broadcast audit event consumed by the <c>AuditWriterActor</c> singleton, which
/// batches and idempotently inserts into <c>ConfigAuditLog</c>.
/// </summary>
public sealed record AuditEvent(
Guid EventId,
string Category,
string Action,
string Actor,
DateTime OccurredAtUtc,
string? DetailsJson,
NodeId SourceNode,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,15 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
public enum ApplyAckOutcome { Applied, Failed }
/// <summary>
/// Per-node acknowledgment returned by <c>DriverHostActor</c> to the dispatching coordinator.
/// </summary>
public sealed record ApplyAck(
DeploymentId DeploymentId,
NodeId NodeId,
ApplyAckOutcome Outcome,
string? FailureReason,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,14 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
/// <summary>
/// Coordinator-published event indicating that the deployment failed and was rolled back.
/// Includes the set of nodes that NACKed or timed out so the admin UI can surface which
/// node(s) are sticky on the prior good revision.
/// </summary>
public sealed record DeploymentFailed(
DeploymentId DeploymentId,
string FailureReason,
IReadOnlyList<NodeId> FailedNodes,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,13 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
/// <summary>
/// Coordinator-published event indicating that every active driver node successfully applied
/// the deployment and the row in <c>Deployment</c> has been transitioned to <c>Sealed</c>.
/// </summary>
public sealed record DeploymentSealed(
DeploymentId DeploymentId,
RevisionHash RevisionHash,
DateTime SealedAtUtc,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,13 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Deploy;
/// <summary>
/// Sent from the admin-role <c>ConfigPublishCoordinator</c> singleton to each driver node's
/// <c>DriverHostActor</c>. Tells the node to fetch the deployment artifact identified by
/// <paramref name="DeploymentId"/> + <paramref name="RevisionHash"/> and apply it.
/// </summary>
public sealed record DispatchDeployment(
DeploymentId DeploymentId,
RevisionHash RevisionHash,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,21 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Fleet;
public enum FleetNodeHealth { Healthy, Degraded, Unreachable }
public sealed record FleetNodeStatus(
NodeId NodeId,
FleetNodeHealth Health,
RevisionHash? CurrentRevision,
DateTime LastSeenUtc);
/// <summary>
/// Periodic fleet-wide status broadcast pushed by <c>FleetStatusBroadcaster</c> to admin UI
/// subscribers via SignalR.
/// </summary>
public sealed record FleetStatusChanged(
IReadOnlyList<FleetNodeStatus> Nodes,
DeploymentId? CurrentDeployment,
DateTime AsOfUtc,
CorrelationId CorrelationId);

View File

@@ -0,0 +1,16 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Redundancy;
public enum RedundancyRole { Primary, Secondary, Detached }
/// <summary>
/// Snapshot of a single node's redundancy state. Aggregated by <c>RedundancyStateActor</c>
/// to compute fleet-wide ServiceLevel.
/// </summary>
public sealed record NodeRedundancyState(
NodeId NodeId,
RedundancyRole Role,
bool IsClusterLeader,
bool IsRoleLeaderForDriver,
DateTime AsOfUtc);

View File

@@ -0,0 +1,11 @@
using ZB.MOM.WW.OtOpcUa.Commons.Types;
namespace ZB.MOM.WW.OtOpcUa.Commons.Messages.Redundancy;
/// <summary>
/// Broadcast whenever the cluster's redundancy topology changes (node up/down, role-leader
/// change, partition heal). Subscribers compute their local OPC UA ServiceLevel from this.
/// </summary>
public sealed record RedundancyStateChanged(
IReadOnlyList<NodeRedundancyState> Nodes,
CorrelationId CorrelationId);