Skip to content

Commit 9e8ef56

Browse files
authored
Allow setting the number of runtime workers to be used. (#258)
This change adds a new configuration parameter called `worker_threads` that allows setting the number of workers the Tokio Runtime will use. It defaults to 4 to maintain backward compatibility. Given that the config file parse is done asynchronously, first, a transient runtime is created for reading config, and once it has been parsed, the actual runtime that will be used for PgCat execution is created.
1 parent 99247f7 commit 9e8ef56

File tree

3 files changed

+221
-193
lines changed

3 files changed

+221
-193
lines changed

pgcat.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ log_client_disconnections = false
4444
# Reload config automatically if it changes.
4545
autoreload = false
4646

47+
# Number of worker threads the Runtime will use (4 by default).
48+
worker_threads = 5
49+
4750
# TLS
4851
# tls_certificate = "server.cert"
4952
# tls_private_key = "server.key"

src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ pub struct General {
178178
#[serde(default = "General::default_ban_time")]
179179
pub ban_time: i64,
180180

181+
#[serde(default = "General::default_worker_threads")]
182+
pub worker_threads: usize,
183+
181184
#[serde(default)] // False
182185
pub autoreload: bool,
183186

@@ -219,6 +222,10 @@ impl General {
219222
pub fn default_ban_time() -> i64 {
220223
60
221224
}
225+
226+
pub fn default_worker_threads() -> usize {
227+
4
228+
}
222229
}
223230

224231
impl Default for General {
@@ -234,6 +241,7 @@ impl Default for General {
234241
healthcheck_timeout: Self::default_healthcheck_timeout(),
235242
healthcheck_delay: Self::default_healthcheck_delay(),
236243
ban_time: Self::default_ban_time(),
244+
worker_threads: Self::default_worker_threads(),
237245
log_client_connections: false,
238246
log_client_disconnections: false,
239247
autoreload: false,

0 commit comments

Comments
 (0)