From 8598e443d8b2e7b336118339aadb3711216d13ff Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sat, 17 Dec 2022 23:19:48 -0600 Subject: [PATCH] wip: add configuration for future feature (client concurrent db limits) --- config.toml | 12 ++++++++++-- src/config.rs | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config.toml b/config.toml index 28ad0eb..8b5afe9 100644 --- a/config.toml +++ b/config.toml @@ -62,14 +62,22 @@ reject_future_seconds = 1800 [limits] # Limit events created per second, averaged over one minute. Must be -# an integer. If not set (or set to 0), defaults to unlimited. -#messages_per_sec = 0 +# an integer. If not set (or set to 0), defaults to unlimited. Note: +# this is for the server as a whole, not per-connection. +# messages_per_sec = 0 # Limit client subscriptions created per second, averaged over one # minute. Must be an integer. If not set (or set to 0), defaults to # unlimited. #subscriptions_per_min = 0 +# UNIMPLEMENTED... +# Limit how many concurrent database connections a client can have. +# This prevents a single client from starting too many expensive +# database queries. Must be an integer. If not set (or set to 0), +# defaults to unlimited (subject to subscription limits). +#db_conns_per_client = 0 + # Limit the maximum size of an EVENT message. Defaults to 128 KB. # Set to 0 for unlimited. #max_event_bytes = 131072 diff --git a/src/config.rs b/src/config.rs index 53fa7c3..75011b0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -53,7 +53,8 @@ pub struct Retention { pub struct Limits { pub messages_per_sec: Option, // Artificially slow down event writing to limit disk consumption (averaged over 1 minute) pub subscriptions_per_min: Option, // Artificially slow down request (db query) creation to prevent abuse (averaged over 1 minute) - pub max_event_bytes: Option, // Maximum size of an EVENT message + pub db_conns_per_client: Option, // How many concurrent database queries (not subscriptions) may a client have? + pub max_event_bytes: Option, // Maximum size of an EVENT message pub max_ws_message_bytes: Option, pub max_ws_frame_bytes: Option, pub broadcast_buffer: usize, // events to buffer for subscribers (prevents slow readers from consuming memory) @@ -216,6 +217,7 @@ impl Default for Settings { limits: Limits { messages_per_sec: None, subscriptions_per_min: None, + db_conns_per_client: None, max_event_bytes: Some(2 << 17), // 128K max_ws_message_bytes: Some(2 << 17), // 128K max_ws_frame_bytes: Some(2 << 17), // 128K