using System.Collections.Generic;

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Host.Backend.Historian
{
    /// <summary>
    ///     Wonderware Historian SDK configuration. Populated from environment variables at Host
    ///     startup (see <c>Program.cs</c>) or from the Proxy's <c>DriverInstance.DriverConfig</c>
    ///     section passed during OpenSession. Kept OPC-UA-free — the Proxy side owns UA translation.
    /// </summary>
    public sealed class HistorianConfiguration
    {
        public bool Enabled { get; set; } = false;

        /// <summary>Single-node fallback when <see cref="ServerNames"/> is empty.</summary>
        public string ServerName { get; set; } = "localhost";

        /// <summary>
        ///     Ordered cluster nodes. When non-empty, the data source tries each in order on connect,
        ///     falling through to the next on failure. A failed node is placed in cooldown for
        ///     <see cref="FailureCooldownSeconds"/> before being re-eligible.
        /// </summary>
        public List<string> ServerNames { get; set; } = new();

        public int FailureCooldownSeconds { get; set; } = 60;
        public bool IntegratedSecurity { get; set; } = true;
        public string? UserName { get; set; }
        public string? Password { get; set; }
        public int Port { get; set; } = 32568;
        public int CommandTimeoutSeconds { get; set; } = 30;
        public int MaxValuesPerRead { get; set; } = 10000;

        /// <summary>
        ///     Outer safety timeout applied to sync-over-async Historian operations. Must be
        ///     comfortably larger than <see cref="CommandTimeoutSeconds"/>.
        /// </summary>
        public int RequestTimeoutSeconds { get; set; } = 60;
    }
}
