using ZB.MOM.WW.OtOpcUa.Commons.Messages.Drivers; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Hubs; /// /// Singleton last-snapshot-per-(instance, host) cache of driver resilience status /// (breaker open / consecutive failures / in-flight depth). Populated by /// DriverResilienceStatusBridge as it forwards driver-resilience-status DPS /// messages; read in-process by the driver status panel's resilience section via /// + . Mirrors /// — the panel reads this singleton directly instead of /// opening a self-targeted SignalR connection (which a server-side Blazor component cannot reach /// behind a reverse proxy). /// public interface IDriverResilienceStatusStore { /// Stores or replaces the last-known resilience snapshot for a (instance, host) pair. /// The resilience status snapshot to store. void Upsert(DriverResilienceStatusChanged snapshot); /// Returns every stored host snapshot for one driver instance (empty if none). /// The driver instance's stable logical ID. /// The per-host resilience snapshots for that instance. IReadOnlyList GetForInstance(string driverInstanceId); /// Returns a point-in-time snapshot of every tracked (instance, host) pair. /// A read-only collection of the last-known resilience snapshot for each pair. IReadOnlyCollection GetAll(); /// /// Evicts every snapshot whose driver instance is not in /// and whose last publish is older than . The stores have no other /// removal path, so a deleted (or re-created under a new id) driver would otherwise keep its last /// snapshot until the process restarts. Both conditions are required: the configured set comes from /// the AUTHORED (draft) table, so a driver deleted in /raw but not yet deployed is still /// running and still publishing — it must stay visible until a deploy actually stops it and its /// snapshot goes stale. The /hosts page calls this after each successful config load; a failed /// load must never call it. /// /// The configured driver-instance ids to keep. The set's own /// comparer decides matching. /// Only an unconfigured entry published before this instant is evicted. /// The number of entries removed. int EvictUnconfiguredStale(IReadOnlySet configuredInstanceIds, DateTime olderThanUtc); /// /// Raised after every with the just-stored snapshot. Lets the Blazor Server /// driver status panel receive live updates by reading this singleton directly. Handlers run on /// the caller's thread (the bridge actor), so subscribers must marshal to their own sync context. /// event Action? SnapshotChanged; }