49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
namespace SOR.Gateway;
|
|
|
|
/// <summary>
|
|
/// Configuration options for the Gateway service.
|
|
/// Bound from the "Gateway" section of appsettings.json.
|
|
///
|
|
/// appsettings.json example:
|
|
/// {
|
|
/// "Gateway": {
|
|
/// "AuthTimeoutMs": 10000,
|
|
/// "MaxMessagesPerSecond": 20,
|
|
/// "RemoteDispatchTimeoutMs": 3000
|
|
/// }
|
|
/// }
|
|
/// </summary>
|
|
public sealed class GatewayOptions
|
|
{
|
|
/// <summary>
|
|
/// How long the Gateway waits for an auth.hello message after a connection is accepted.
|
|
/// If the client does not send auth.hello within this window, the connection is closed
|
|
/// with an "auth_timeout" reason.
|
|
/// Default: 10 seconds.
|
|
/// </summary>
|
|
public int AuthTimeoutMs { get; set; } = 10_000;
|
|
|
|
/// <summary>
|
|
/// Maximum number of messages per second the Gateway will process per connection.
|
|
/// Connections exceeding this rate receive a "rate_limit_exceeded" error and are
|
|
/// disconnected. Protects against runaway clients flooding the server.
|
|
///
|
|
/// Note: rate limiting is tracked per connection, not per user.
|
|
/// If a user opens multiple connections they get this budget per connection.
|
|
///
|
|
/// Set to 0 to disable rate limiting (not recommended for production).
|
|
/// Default: 20 messages per second.
|
|
///
|
|
/// Implementation: tracked in ConnectionLoop but not enforced in this foundation phase.
|
|
/// This option is defined now so configuration is in place before enforcement is added.
|
|
/// </summary>
|
|
public int MaxMessagesPerSecond { get; set; } = 20;
|
|
|
|
/// <summary>
|
|
/// Maximum time the Gateway waits for an internal worker to reply to a relayed
|
|
/// client message before returning an error to the client.
|
|
/// Default: 3 seconds.
|
|
/// </summary>
|
|
public int RemoteDispatchTimeoutMs { get; set; } = 3_000;
|
|
}
|