Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.Communication/Actors/NoOpCentralTransport.cs
T
Joseph Doherty 7fd5cb2b56 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.
2026-07-23 12:54:32 -04:00

63 lines
3.2 KiB
C#

using Akka.Actor;
using Akka.Event;
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;
namespace ZB.MOM.WW.ScadaBridge.Communication.Actors;
/// <summary>
/// The <see cref="ICentralTransport"/> used only when the Host injects none — a fail-loud placeholder,
/// not a working transport. Production always injects <see cref="Grpc.GrpcCentralTransport"/>; a null
/// here is a wiring bug, so every send warns and each Ask-returning method answers a
/// <see cref="Status.Failure"/> so the caller sees the same transient failure the old ClusterClient
/// path produced when no client was registered (rows stay buffered, the pass re-runs). The heartbeat
/// stays fire-and-forget: swallowed and logged, never faulting the heartbeat timer.
/// </summary>
/// <remarks>
/// This replaced the previous default (<c>AkkaCentralTransport</c> with no registered ClusterClient),
/// deleted when the site→central path became gRPC-only in the ClusterClient→gRPC migration's Phase 4.
/// It exists mostly so TestKit suites that only exercise central→site command dispatch — and never
/// inject a transport — construct the actor without wiring a real channel.
/// </remarks>
public sealed class NoOpCentralTransport : ICentralTransport
{
private readonly ILoggingAdapter _log;
/// <summary>Creates the placeholder transport with the owning actor's logging adapter.</summary>
/// <param name="log">The actor's logging adapter, used for the "no transport configured" warnings.</param>
public NoOpCentralTransport(ILoggingAdapter log) => _log = log;
private void Fail(string what, IActorRef replyTo)
{
_log.Warning(
"No site→central transport is configured; dropping {0} as a transient failure. This is a "
+ "wiring bug — the Host must inject a GrpcCentralTransport.", what);
replyTo.Tell(new Status.Failure(new InvalidOperationException(
$"No site→central transport configured (dropping {what}).")));
}
/// <inheritdoc />
public void SubmitNotification(NotificationSubmit message, IActorRef replyTo) => Fail(nameof(SubmitNotification), replyTo);
/// <inheritdoc />
public void QueryNotificationStatus(NotificationStatusQuery message, IActorRef replyTo) => Fail(nameof(QueryNotificationStatus), replyTo);
/// <inheritdoc />
public void IngestAuditEvents(IngestAuditEventsCommand message, IActorRef replyTo) => Fail(nameof(IngestAuditEvents), replyTo);
/// <inheritdoc />
public void IngestCachedTelemetry(IngestCachedTelemetryCommand message, IActorRef replyTo) => Fail(nameof(IngestCachedTelemetry), replyTo);
/// <inheritdoc />
public void ReconcileSite(ReconcileSiteRequest message, IActorRef replyTo) => Fail(nameof(ReconcileSite), replyTo);
/// <inheritdoc />
public void ReportSiteHealth(SiteHealthReport message, IActorRef replyTo) => Fail(nameof(ReportSiteHealth), replyTo);
/// <inheritdoc />
public void SendHeartbeat(HeartbeatMessage message, IActorRef self) =>
_log.Warning("No site→central transport is configured; heartbeat dropped (wiring bug).");
}