feat(comm): Phase 4 — delete Akka ClusterClient site↔central transport, gRPC-only
ClusterClient→gRPC migration Phase 4 (docs/plans/2026-07-22-clusterclient-to-grpc-plan.md). Phases 2/3 proved both directions on gRPC; this removes the Akka transport underneath. Deleted: - AkkaCentralTransport, AkkaSiteTransport (+ their dedicated tests) - ISiteClientFactory + DefaultSiteClientFactory; CentralCommunicationActor legacy ctor + SelectTransport (Host now builds GrpcSiteTransport and injects it) - ClusterClient creation + both ClusterClientReceptionist.RegisterService calls in AkkaHostedService; the RegisterCentralClient message + receive block - CommunicationOptions.CentralContactPoints; the CentralTransport/SiteTransport coexistence flags; the CentralTransportMode/SiteTransportKind enums gRPC is now the only site↔central transport (site→central CentralControlService via GrpcCentralTransport; central→site SiteCommandService via GrpcSiteTransport), both built unconditionally by the Host. NoOpCentralTransport is the fail-loud null-default so TestKit command-dispatch suites still construct the site actor without a wired transport; production always injects GrpcCentralTransport. Config: CentralGrpcEndpoints is now unconditional — CommunicationOptionsValidator rejects blank entries (role-agnostic), and StartupValidator requires a Site node to list >=1 endpoint (fail-fast, mirrors GrpcPsk). Rig configs moved CentralContactPoints -> CentralGrpcEndpoints (docker x6, docker-env2 x2, Host default, deploy/wonder-app-vd03). Kept Akka.Cluster.Tools (ClusterSingleton still used). Tests: build 0/0; Communication.Tests 640, Host.Tests 421 green. Removed the ClusterClient.Send per-site-routing tests (covered by the transport suites), swapped the ISiteClientFactory-based ctors to a substitute ISiteCommandTransport, converted the audit-push integration relay to an in-process bridge transport. Docs: Component-Communication/Host/StoreAndForward, components/Communication, topology-guide, grpc_streams (SUPERSEDED note), the frame-size known-issue (retired amendment), and CLAUDE.md transport decisions. Not included: the dead IntegrationCallRequest path (#32) is a separate user-owned behavioral decision — SiteEnvelope routing is transport-agnostic so it still compiles.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Immutable;
|
||||
using Akka.Actor;
|
||||
using Akka.Cluster.Tools.Client;
|
||||
using Akka.TestKit.Xunit2;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
@@ -12,6 +10,10 @@ using ZB.MOM.WW.ScadaBridge.AuditLog.Site.Telemetry;
|
||||
using ZB.MOM.WW.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Deployment;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Health;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Notification;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
@@ -32,10 +34,10 @@ namespace ZB.MOM.WW.ScadaBridge.IntegrationTests.AuditLog;
|
||||
/// <see cref="ClusterClientSiteAuditClient"/>, the real
|
||||
/// <see cref="SiteCommunicationActor"/> forward, the real
|
||||
/// <see cref="CentralCommunicationActor"/> routing, and the real
|
||||
/// <c>AuditLogIngestActor</c> ingest — only the cross-cluster ClusterClient
|
||||
/// transport itself is substituted by an in-process <see cref="ClusterClientRelay"/>
|
||||
/// that unwraps <see cref="ClusterClient.Send"/> exactly as a real ClusterClient
|
||||
/// would (a multi-node cluster is out of scope for an in-process test).
|
||||
/// <c>AuditLogIngestActor</c> ingest — only the cross-cluster gRPC transport itself is
|
||||
/// substituted by an in-process <see cref="BridgeCentralTransport"/> that Tells the central
|
||||
/// actor exactly as the real <c>GrpcCentralTransport</c> would (a multi-node cluster is out of
|
||||
/// scope for an in-process test).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The central audit store is an in-memory <see cref="IAuditLogRepository"/> —
|
||||
@@ -49,18 +51,23 @@ namespace ZB.MOM.WW.ScadaBridge.IntegrationTests.AuditLog;
|
||||
public class SiteAuditPushFlowTests : TestKit
|
||||
{
|
||||
/// <summary>
|
||||
/// In-process stand-in for a real Akka ClusterClient: unwraps a
|
||||
/// <see cref="ClusterClient.Send"/> and forwards the inner message to the
|
||||
/// central actor, preserving the original sender so the reply routes back to
|
||||
/// the site's Ask. A real ClusterClient does exactly this across the cluster
|
||||
/// boundary; the in-process relay keeps the test free of a multi-node setup.
|
||||
/// In-process stand-in for the site→central gRPC transport (<c>GrpcCentralTransport</c>):
|
||||
/// each site→central send is Tell'd straight to the central actor, preserving the reply-to so
|
||||
/// the central reply routes back to the site's Ask. A real transport does exactly this across
|
||||
/// the cluster boundary; the in-process bridge keeps the test free of a multi-node/gRPC setup.
|
||||
/// </summary>
|
||||
private sealed class ClusterClientRelay : ReceiveActor
|
||||
private sealed class BridgeCentralTransport : ICentralTransport
|
||||
{
|
||||
public ClusterClientRelay(IActorRef central)
|
||||
{
|
||||
Receive<ClusterClient.Send>(send => central.Forward(send.Message));
|
||||
}
|
||||
private readonly IActorRef _central;
|
||||
public BridgeCentralTransport(IActorRef central) => _central = central;
|
||||
|
||||
public void SubmitNotification(NotificationSubmit message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void QueryNotificationStatus(NotificationStatusQuery message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void IngestAuditEvents(IngestAuditEventsCommand message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void IngestCachedTelemetry(IngestCachedTelemetryCommand message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void ReconcileSite(ReconcileSiteRequest message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void ReportSiteHealth(SiteHealthReport message, IActorRef replyTo) => _central.Tell(message, replyTo);
|
||||
public void SendHeartbeat(HeartbeatMessage message, IActorRef self) => _central.Tell(message, self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +155,7 @@ public class SiteAuditPushFlowTests : TestKit
|
||||
|
||||
var centralCommActor = Sys.ActorOf(Props.Create(() => new CentralCommunicationActor(
|
||||
centralProvider,
|
||||
new DefaultSiteClientFactory(),
|
||||
Substitute.For<ISiteCommandTransport>(),
|
||||
TimeSpan.FromSeconds(5))));
|
||||
centralCommActor.Tell(new RegisterAuditIngest(ingestActor));
|
||||
|
||||
@@ -162,14 +169,15 @@ public class SiteAuditPushFlowTests : TestKit
|
||||
await using var writer = new SqliteAuditWriter(
|
||||
writerOptions, NullLogger<SqliteAuditWriter>.Instance, nodeIdentity);
|
||||
|
||||
// Real SiteCommunicationActor. RegisterCentralClient is given the relay
|
||||
// standing in for the central ClusterClient.
|
||||
// Real SiteCommunicationActor. Its site→central transport is the in-process bridge that
|
||||
// Tells the central actor (standing in for GrpcCentralTransport dialling CentralControlService).
|
||||
var siteCommActor = Sys.ActorOf(Props.Create(() => new SiteCommunicationActor(
|
||||
"site-1",
|
||||
new CommunicationOptions(),
|
||||
CreateTestProbe().Ref))); // deployment-manager proxy is unused here
|
||||
var relay = Sys.ActorOf(Props.Create(() => new ClusterClientRelay(centralCommActor)));
|
||||
siteCommActor.Tell(new RegisterCentralClient(relay));
|
||||
CreateTestProbe().Ref, // deployment-manager proxy is unused here
|
||||
null,
|
||||
null,
|
||||
new BridgeCentralTransport(centralCommActor))));
|
||||
|
||||
// The production site audit push client — the unit under integration.
|
||||
var auditClient = new ClusterClientSiteAuditClient(
|
||||
|
||||
Reference in New Issue
Block a user