using System;
using System.Collections.Generic;
namespace ZB.MOM.WW.OtOpcUa.Host.Historian
{
///
/// Point-in-time runtime health of the historian plugin, surfaced to the status dashboard
/// and health check service. Fills the gap between the load-time plugin status
/// () and actual query behavior so operators
/// can detect silent query degradation.
///
public sealed class HistorianHealthSnapshot
{
///
/// Gets or sets the total number of historian read operations attempted since startup
/// across all read paths (raw, aggregate, at-time, events).
///
public long TotalQueries { get; set; }
///
/// Gets or sets the total number of read operations that completed without an exception
/// being caught by the plugin's error handler. Includes empty result sets as successes —
/// the counter reflects "the SDK call returned" not "the SDK call returned data".
///
public long TotalSuccesses { get; set; }
///
/// Gets or sets the total number of read operations that raised an exception. Each failure
/// also resets and closes the underlying SDK connection via the existing reconnect path.
///
public long TotalFailures { get; set; }
///
/// Gets or sets the number of consecutive failures since the last success. Latches until
/// a successful query clears it. The health check service uses this as a degradation signal.
///
public int ConsecutiveFailures { get; set; }
///
/// Gets or sets the UTC timestamp of the last successful read, or
/// when no query has succeeded since startup.
///
public DateTime? LastSuccessTime { get; set; }
///
/// Gets or sets the UTC timestamp of the last failure, or when no
/// query has failed since startup.
///
public DateTime? LastFailureTime { get; set; }
///
/// Gets or sets the exception message from the most recent failure. Cleared on the next
/// successful query.
///
public string? LastError { get; set; }
///
/// Gets or sets a value indicating whether the plugin currently holds an open SDK
/// connection for the process (historical values) path.
///
public bool ProcessConnectionOpen { get; set; }
///
/// Gets or sets a value indicating whether the plugin currently holds an open SDK
/// connection for the event (alarm history) path.
///
public bool EventConnectionOpen { get; set; }
///
/// Gets or sets the node the plugin is currently connected to for the process path,
/// or when no connection is open.
///
public string? ActiveProcessNode { get; set; }
///
/// Gets or sets the node the plugin is currently connected to for the event path,
/// or when no event connection is open.
///
public string? ActiveEventNode { get; set; }
///
/// Gets or sets the total number of configured historian cluster nodes. A value of 1
/// reflects a legacy single-node deployment.
///
public int NodeCount { get; set; }
///
/// Gets or sets the number of configured nodes that are currently healthy (not in cooldown).
///
public int HealthyNodeCount { get; set; }
///
/// Gets or sets the per-node cluster state in configuration order.
///
public List Nodes { get; set; } = new();
}
}