using ZB.MOM.WW.ScadaBridge.Commons.Messages.Health; namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring; /// /// Interface for central-side health aggregation. /// Consumed by Central UI to display site health dashboards. /// public interface ICentralHealthAggregator { /// /// Processes an incoming health report from a site and updates the aggregated state. /// /// The health report received from the site. void ProcessReport(SiteHealthReport report); /// /// Bumps the last-seen timestamp for a site, keeping it marked online /// between full 30s reports when heartbeats are arriving — protects against /// the offline threshold firing on a transiently delayed report. Heartbeat /// cadence is owned by the Cluster Infrastructure / SiteCommunicationActor /// (the application-level heartbeat to central, sent every /// CommunicationOptions.TransportHeartbeatInterval — 5s by default); /// the 60s therefore /// tolerates several missed heartbeats. A heartbeat for a site with no /// aggregator state yet (e.g. just after a central restart/failover) /// registers that site as online with no /// , so reachable sites are not /// shown as "unknown" during the failover window. /// /// The string identifier of the site that sent the heartbeat. /// The UTC timestamp when the heartbeat was received. void MarkHeartbeat(string siteId, DateTimeOffset receivedAt); /// Returns a snapshot of all currently tracked site health states. /// A dictionary mapping site id to its current . IReadOnlyDictionary GetAllSiteStates(); /// Returns the current health state for the specified site, or null if not tracked. /// The string identifier of the site to look up. /// The for the site, or null if not yet seen. SiteHealthState? GetSiteState(string siteId); /// /// Removes tracked sites not in (i.e. deleted /// from configuration). The synthetic central id is always retained. /// Self-healing: called from the CentralCommunicationActor's periodic site /// refresh, so a deleted site disappears within one refresh interval without /// needing a dedicated deletion event. Without this the in-memory state only /// ever grew, leaving a deleted site as a permanently-offline dashboard tile /// (and a live KPI sample source) forever. /// /// The identifiers of all currently-configured sites. void PruneUnknownSites(IReadOnlyCollection knownSiteIds); }