namespace ZB.MOM.WW.MxGateway.Server.Configuration; public sealed class SessionOptions { /// /// Gets the default command timeout in seconds. /// public int DefaultCommandTimeoutSeconds { get; init; } = 30; /// /// Gets the maximum number of concurrent sessions. /// public int MaxSessions { get; init; } = 64; /// /// Gets the maximum number of pending commands per session. /// public int MaxPendingCommandsPerSession { get; init; } = 128; /// Gets the default session lease duration in seconds. public int DefaultLeaseSeconds { get; init; } = 1800; /// Gets the interval for sweeping expired session leases in seconds. public int LeaseSweepIntervalSeconds { get; init; } = 30; /// /// Gets the detach-grace retention window, in seconds, that a session is kept alive /// after its last external (gRPC) event-stream subscriber drops, so a client can /// reconnect to it. While within the window the session stays in /// Ready and remains usable; if no new external subscriber attaches before the /// window elapses, the lease monitor closes the session exactly as it closes an /// expired lease. The gateway-owned internal dashboard subscriber does not count as an /// external subscriber, so a session whose only remaining subscriber is the dashboard /// mirror still enters detach-grace. A value of 0 disables retention: the /// session reverts to the original behavior of lingering only until its normal lease /// expires. The reconnect/replay itself is implemented separately; this /// option controls retention and expiry only. /// /// /// The effective close happens within the next sweep cycle after the window elapses — /// up to after expiry. Operators who want a /// firm minimum bound should set DetachGraceSeconds greater than /// ; otherwise a session whose window expires /// just before a sweep run may be closed within seconds of detach. /// public int DetachGraceSeconds { get; init; } = 30; /// /// Gets a value indicating whether multiple event subscribers are allowed per session. /// public bool AllowMultipleEventSubscribers { get; init; } /// /// Gets the maximum number of concurrent event subscribers per session. /// Applies when is ; /// effectively 1 when it is . Must be greater than zero. /// public int MaxEventSubscribersPerSession { get; init; } = 8; /// /// Gets the bounded time, in milliseconds, the gateway will wait for a worker client /// to reach Ready when the session itself is already Ready but the worker /// state has transiently diverged (e.g. Handshaking after a heartbeat blip). /// The wait applies only to transient worker states; terminal states /// (Faulted/Closing/Closed/no worker) fail fast immediately. /// A value of 0 (the default) disables the wait — the gateway keeps the original /// fail-fast behavior. Must be greater than or equal to zero. /// public int WorkerReadyWaitTimeoutMs { get; init; } }