namespace ScadaLink.Communication;

/// <summary>
/// Configuration options for central-site communication, including per-pattern
/// timeouts and transport heartbeat settings.
/// </summary>
public class CommunicationOptions
{
    /// <summary>Timeout for deployment commands (typically longest due to apply logic).</summary>
    public TimeSpan DeploymentTimeout { get; set; } = TimeSpan.FromMinutes(2);

    /// <summary>Timeout for lifecycle commands (disable, enable, delete).</summary>
    public TimeSpan LifecycleTimeout { get; set; } = TimeSpan.FromSeconds(30);

    /// <summary>Timeout for artifact deployment commands.</summary>
    public TimeSpan ArtifactDeploymentTimeout { get; set; } = TimeSpan.FromMinutes(1);

    /// <summary>Timeout for remote query requests (event logs, parked messages).</summary>
    public TimeSpan QueryTimeout { get; set; } = TimeSpan.FromSeconds(30);

    /// <summary>Timeout for integration call routing.</summary>
    public TimeSpan IntegrationTimeout { get; set; } = TimeSpan.FromSeconds(30);

    /// <summary>Timeout for debug view subscribe/unsubscribe handshake.</summary>
    public TimeSpan DebugViewTimeout { get; set; } = TimeSpan.FromSeconds(10);

    /// <summary>Timeout for health report acknowledgement (fire-and-forget, but bounded).</summary>
    public TimeSpan HealthReportTimeout { get; set; } = TimeSpan.FromSeconds(10);

    /// <summary>
    /// Contact point addresses for the central cluster (e.g. "akka.tcp://scadalink@central-a:8081").
    /// Used by site nodes to create a ClusterClient for reaching central.
    /// </summary>
    public List<string> CentralContactPoints { get; set; } = new();

    /// <summary>gRPC keepalive ping interval for streaming connections.</summary>
    public TimeSpan GrpcKeepAlivePingDelay { get; set; } = TimeSpan.FromSeconds(15);

    /// <summary>gRPC keepalive ping timeout — stream is considered dead if no response within this period.</summary>
    public TimeSpan GrpcKeepAlivePingTimeout { get; set; } = TimeSpan.FromSeconds(10);

    /// <summary>Maximum lifetime for a single gRPC stream before the server forces re-establishment.</summary>
    public TimeSpan GrpcMaxStreamLifetime { get; set; } = TimeSpan.FromHours(4);

    /// <summary>Maximum number of concurrent gRPC streaming subscriptions per site node.</summary>
    public int GrpcMaxConcurrentStreams { get; set; } = 100;

    /// <summary>Akka.Remote transport heartbeat interval.</summary>
    public TimeSpan TransportHeartbeatInterval { get; set; } = TimeSpan.FromSeconds(5);

    /// <summary>Akka.Remote transport failure detection threshold.</summary>
    public TimeSpan TransportFailureThreshold { get; set; } = TimeSpan.FromSeconds(15);
}
