namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring;

public class HealthMonitoringOptions
{
    /// <summary>Interval at which sites emit health reports to the central cluster.</summary>
    public TimeSpan ReportInterval { get; set; } = TimeSpan.FromSeconds(30);
    /// <summary>Duration of silence after which a site is classified as offline.</summary>
    public TimeSpan OfflineTimeout { get; set; } = TimeSpan.FromMinutes(1);

    /// <summary>
    /// Offline timeout applied to the synthetic "central" site only. Real sites
    /// emit frequent heartbeats that keep <c>LastHeartbeatAt</c> fresh, so the
    /// normal <see cref="OfflineTimeout"/> only fires on genuine total loss. The
    /// "central" self-report has no heartbeat source — its only signal is the
    /// 30s <see cref="CentralHealthReportLoop"/>, so a single skipped/late
    /// self-report (leader GC pause, brief stall, mid-failover before the new
    /// leader's loop spins up) would flap it offline under the 60s site timeout.
    /// A longer central grace gives the equivalent of "one missed report" that
    /// the design doc grants real sites. Default: 3x the report interval.
    /// </summary>
    public TimeSpan CentralOfflineTimeout { get; set; } = TimeSpan.FromMinutes(3);

    /// <summary>
    /// Duration an online site may go without a full health <em>report</em>
    /// (heartbeats notwithstanding) before it is flagged
    /// <see cref="SiteHealthState.IsMetricsStale"/>. Distinct from
    /// <see cref="OfflineTimeout"/>, which is heartbeat-based liveness: a site
    /// whose HealthReportSender has died keeps heartbeating and stays "online",
    /// but its metrics freeze — this window surfaces that. Must be positive and
    /// no shorter than <see cref="ReportInterval"/> (a window shorter than one
    /// report interval would flag every healthy site). Default: 2 minutes
    /// (~4 missed 30s reports).
    /// </summary>
    public TimeSpan MetricsStaleTimeout { get; set; } = TimeSpan.FromMinutes(2);
}
