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; /// /// The used only when the Host injects none — a fail-loud placeholder, /// not a working transport. Production always injects ; a null /// here is a wiring bug, so every send warns and each Ask-returning method answers a /// 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. /// /// /// This replaced the previous default (AkkaCentralTransport 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. /// public sealed class NoOpCentralTransport : ICentralTransport { private readonly ILoggingAdapter _log; /// Creates the placeholder transport with the owning actor's logging adapter. /// The actor's logging adapter, used for the "no transport configured" warnings. 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})."))); } /// public void SubmitNotification(NotificationSubmit message, IActorRef replyTo) => Fail(nameof(SubmitNotification), replyTo); /// public void QueryNotificationStatus(NotificationStatusQuery message, IActorRef replyTo) => Fail(nameof(QueryNotificationStatus), replyTo); /// public void IngestAuditEvents(IngestAuditEventsCommand message, IActorRef replyTo) => Fail(nameof(IngestAuditEvents), replyTo); /// public void IngestCachedTelemetry(IngestCachedTelemetryCommand message, IActorRef replyTo) => Fail(nameof(IngestCachedTelemetry), replyTo); /// public void ReconcileSite(ReconcileSiteRequest message, IActorRef replyTo) => Fail(nameof(ReconcileSite), replyTo); /// public void ReportSiteHealth(SiteHealthReport message, IActorRef replyTo) => Fail(nameof(ReportSiteHealth), replyTo); /// public void SendHeartbeat(HeartbeatMessage message, IActorRef self) => _log.Warning("No site→central transport is configured; heartbeat dropped (wiring bug)."); }