using ScadaLink.Commons.Types.Enums;

namespace ScadaLink.Commons.Messages.Health;

public record SiteHealthReport(
    string SiteId,
    long SequenceNumber,
    DateTimeOffset ReportTimestamp,
    IReadOnlyDictionary<string, ConnectionHealth> DataConnectionStatuses,
    IReadOnlyDictionary<string, TagResolutionStatus> TagResolutionCounts,
    int ScriptErrorCount,
    int AlarmEvaluationErrorCount,
    IReadOnlyDictionary<string, int> StoreAndForwardBufferDepths,
    int DeadLetterCount,
    int DeployedInstanceCount,
    int EnabledInstanceCount,
    int DisabledInstanceCount,
    string NodeRole = "Unknown",
    string NodeHostname = "",
    IReadOnlyDictionary<string, string>? DataConnectionEndpoints = null,
    IReadOnlyDictionary<string, TagQualityCounts>? DataConnectionTagQuality = null,
    int ParkedMessageCount = 0,
    IReadOnlyList<NodeStatus>? ClusterNodes = null);

/// <summary>
/// Broadcast wrapper used between central nodes to keep per-node
/// CentralHealthAggregator state in sync. ClusterClient load-balances each
/// incoming SiteHealthReport to one central node; that node re-publishes
/// this wrapper on a DistributedPubSub topic so the peer node's aggregator
/// also processes the report (idempotently — sequence numbers guard against
/// double-counting).
/// </summary>
public record SiteHealthReportReplica(SiteHealthReport Report);
