namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;

/// <summary>
///     Point-in-time runtime health of a historian data source. Returned by
///     <see cref="IHistorianDataSource.GetHealthSnapshot"/> and projected onto the
///     server status dashboard.
/// </summary>
/// <param name="TotalQueries">Lifetime count of read calls received.</param>
/// <param name="TotalSuccesses">Subset of <paramref name="TotalQueries"/> that completed without error.</param>
/// <param name="TotalFailures">Subset of <paramref name="TotalQueries"/> that ended in error.</param>
/// <param name="ConsecutiveFailures">Failures since the last success — non-zero means the source is currently degraded.</param>
/// <param name="LastSuccessTime">UTC of the most recent successful read; null if none yet.</param>
/// <param name="LastFailureTime">UTC of the most recent failed read; null if none yet.</param>
/// <param name="LastError">Diagnostic text from the most recent failure; null when no failures recorded.</param>
/// <param name="ProcessConnectionOpen">True when the source's process-data connection is currently established.</param>
/// <param name="EventConnectionOpen">True when the source's event-data connection is currently established. Some backends share one connection — implementations may report the same value here as <paramref name="ProcessConnectionOpen"/>.</param>
/// <param name="ActiveProcessNode">Cluster node currently serving process reads; null when no node is active or the backend is non-clustered.</param>
/// <param name="ActiveEventNode">Cluster node currently serving event reads; null when no node is active or the backend is non-clustered.</param>
/// <param name="Nodes">Per-cluster-node state. Empty when the backend is non-clustered.</param>
public sealed record HistorianHealthSnapshot(
    long TotalQueries,
    long TotalSuccesses,
    long TotalFailures,
    int ConsecutiveFailures,
    DateTime? LastSuccessTime,
    DateTime? LastFailureTime,
    string? LastError,
    bool ProcessConnectionOpen,
    bool EventConnectionOpen,
    string? ActiveProcessNode,
    string? ActiveEventNode,
    IReadOnlyList<HistorianClusterNodeState> Nodes);
