using ScadaLink.Commons.Messages.Health;

namespace ScadaLink.HealthMonitoring;

/// <summary>
/// Interface for central-side health aggregation.
/// Consumed by Central UI to display site health dashboards.
/// </summary>
public interface ICentralHealthAggregator
{
    void ProcessReport(SiteHealthReport report);

    /// <summary>
    /// 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. 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
    /// <see cref="SiteHealthState.LatestReport"/>, so reachable sites are not
    /// shown as "unknown" during the failover window.
    /// </summary>
    void MarkHeartbeat(string siteId, DateTimeOffset receivedAt);

    IReadOnlyDictionary<string, SiteHealthState> GetAllSiteStates();
    SiteHealthState? GetSiteState(string siteId);
}
