namespace ZB.MOM.WW.MxGateway.Worker.Bootstrap;

/// <summary>Worker bootstrap options passed via environment variables and named pipes.</summary>
public sealed class WorkerOptions
{
    /// <summary>Environment variable name for the worker nonce.</summary>
    public const string NonceEnvironmentVariableName = "MXGATEWAY_WORKER_NONCE";

    /// <summary>Initializes worker options from a bootstrap handshake.</summary>
    /// <param name="sessionId">Identifier of the session.</param>
    /// <param name="pipeName">Named pipe name for gateway communication.</param>
    /// <param name="protocolVersion">Protocol version agreed with the gateway.</param>
    /// <param name="nonce">Authentication nonce for the handshake.</param>
    public WorkerOptions(
        string sessionId,
        string pipeName,
        uint protocolVersion,
        string nonce)
    {
        SessionId = sessionId;
        PipeName = pipeName;
        ProtocolVersion = protocolVersion;
        Nonce = nonce;
    }

    /// <summary>Unique identifier for the gateway session this worker serves.</summary>
    public string SessionId { get; }

    /// <summary>Named pipe name for communicating with the gateway.</summary>
    public string PipeName { get; }

    /// <summary>Worker protocol version negotiated with the gateway.</summary>
    public uint ProtocolVersion { get; }

    /// <summary>Nonce used to authenticate the handshake with the gateway.</summary>
    public string Nonce { get; }
}
