pub struct RateLimitConfig {
pub max_connections_per_ip: Option<usize>,
pub max_connections_per_metering_key: Option<usize>,
pub max_connections_per_origin: Option<usize>,
pub client_timeout: Duration,
pub message_queue_size: usize,
pub max_reconnect_attempts: Option<u32>,
pub message_rate_window: Duration,
pub egress_rate_window: Duration,
pub default_limits: Option<Limits>,
}Expand description
Configuration for rate limiting in ClientManager
These settings control various rate limits at the connection level. Per-subject limits are controlled via AuthContext.Limits.
Fields§
§max_connections_per_ip: Option<usize>Global maximum connections per IP address
max_connections_per_metering_key: Option<usize>Global maximum connections per metering key
max_connections_per_origin: Option<usize>Global maximum connections per origin
client_timeout: DurationDefault connection timeout for stale client cleanup
message_queue_size: usizeMessage queue size per client
max_reconnect_attempts: Option<u32>Maximum reconnect attempts per client (optional global default)
message_rate_window: DurationRate limit window duration for message counting
egress_rate_window: DurationRate limit window duration for egress tracking
default_limits: Option<Limits>Default limits applied when auth token doesn’t specify limits These act as server-wide fallback limits for all connections
Implementations§
Source§impl RateLimitConfig
impl RateLimitConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Load configuration from environment variables
Environment variables:
HYPERSTACK_WS_MAX_CONNECTIONS_PER_IP- Max connections per IP (default: unlimited)HYPERSTACK_WS_MAX_CONNECTIONS_PER_METERING_KEY- Max connections per metering key (default: unlimited)HYPERSTACK_WS_MAX_CONNECTIONS_PER_ORIGIN- Max connections per origin (default: unlimited)HYPERSTACK_WS_CLIENT_TIMEOUT_SECS- Client timeout in seconds (default: 300)HYPERSTACK_WS_MESSAGE_QUEUE_SIZE- Message queue size per client (default: 512)HYPERSTACK_WS_RATE_LIMIT_WINDOW_SECS- Rate limit window in seconds (default: 60)HYPERSTACK_WS_DEFAULT_MAX_CONNECTIONS- Default max connections per subject (fallback when token has no limit)HYPERSTACK_WS_DEFAULT_MAX_SUBSCRIPTIONS- Default max subscriptions per connection (fallback when token has no limit)HYPERSTACK_WS_DEFAULT_MAX_SNAPSHOT_ROWS- Default max snapshot rows per request (fallback when token has no limit)HYPERSTACK_WS_DEFAULT_MAX_MESSAGES_PER_MINUTE- Default max messages per minute (fallback when token has no limit)HYPERSTACK_WS_DEFAULT_MAX_BYTES_PER_MINUTE- Default max bytes per minute (fallback when token has no limit)
Sourcepub fn with_max_connections_per_ip(self, max: usize) -> Self
pub fn with_max_connections_per_ip(self, max: usize) -> Self
Set the maximum connections per IP
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the client timeout
Sourcepub fn with_message_queue_size(self, size: usize) -> Self
pub fn with_message_queue_size(self, size: usize) -> Self
Set the message queue size
Sourcepub fn with_rate_limit_window(self, window: Duration) -> Self
pub fn with_rate_limit_window(self, window: Duration) -> Self
Set the rate limit window (applies to both message and egress windows)
Sourcepub fn with_default_limits(self, limits: Limits) -> Self
pub fn with_default_limits(self, limits: Limits) -> Self
Set default limits applied when auth token doesn’t specify limits
These limits act as server-wide fallbacks for connections where the authentication token doesn’t include explicit limits.
Trait Implementations§
Source§impl Clone for RateLimitConfig
impl Clone for RateLimitConfig
Source§fn clone(&self) -> RateLimitConfig
fn clone(&self) -> RateLimitConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more