namespace ZB.MOM.WW.LmxProxy.Host.Configuration
{
    /// <summary>Root configuration class bound to appsettings.json.</summary>
    public class LmxProxyConfiguration
    {
        /// <summary>gRPC server listen port. Default: 50051.</summary>
        public int GrpcPort { get; set; } = 50051;

        /// <summary>Path to API key configuration file. Default: apikeys.json.</summary>
        public string ApiKeyConfigFile { get; set; } = "apikeys.json";

        /// <summary>Unique client name for MxAccess Register(). Must be unique per instance. Default: auto-generated.</summary>
        public string? ClientName { get; set; }

        /// <summary>MxAccess connection settings.</summary>
        public ConnectionConfiguration Connection { get; set; } = new ConnectionConfiguration();

        /// <summary>Subscription channel settings.</summary>
        public SubscriptionConfiguration Subscription { get; set; } = new SubscriptionConfiguration();

        /// <summary>TLS/SSL settings.</summary>
        public TlsConfiguration Tls { get; set; } = new TlsConfiguration();

        /// <summary>Status web server settings.</summary>
        public WebServerConfiguration WebServer { get; set; } = new WebServerConfiguration();

        /// <summary>Windows SCM service recovery settings.</summary>
        public ServiceRecoveryConfiguration ServiceRecovery { get; set; } = new ServiceRecoveryConfiguration();

        /// <summary>Health check / active probe settings.</summary>
        public HealthCheckConfiguration HealthCheck { get; set; } = new HealthCheckConfiguration();
    }

    /// <summary>Health check / probe configuration.</summary>
    public class HealthCheckConfiguration
    {
        /// <summary>Tag address to subscribe to for connection liveness. Default: DevPlatform.Scheduler.ScanTime.</summary>
        public string TestTagAddress { get; set; } = "DevPlatform.Scheduler.ScanTime";

        /// <summary>
        ///     Maximum time (ms) without a value update on the test tag before forcing reconnect.
        ///     Default: 5000 (5 seconds).
        /// </summary>
        public int ProbeStaleThresholdMs { get; set; } = 5000;
    }
}
