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.
This commit is contained in:
Jose Fernández
2022-12-16 20:13:13 +01:00
committed by GitHub
parent 99247f7c88
commit 9e8ef566c6
3 changed files with 217 additions and 189 deletions

View File

@@ -178,6 +178,9 @@ pub struct General {
#[serde(default = "General::default_ban_time")]
pub ban_time: i64,
#[serde(default = "General::default_worker_threads")]
pub worker_threads: usize,
#[serde(default)] // False
pub autoreload: bool,
@@ -219,6 +222,10 @@ impl General {
pub fn default_ban_time() -> i64 {
60
}
pub fn default_worker_threads() -> usize {
4
}
}
impl Default for General {
@@ -234,6 +241,7 @@ impl Default for General {
healthcheck_timeout: Self::default_healthcheck_timeout(),
healthcheck_delay: Self::default_healthcheck_delay(),
ban_time: Self::default_ban_time(),
worker_threads: Self::default_worker_threads(),
log_client_connections: false,
log_client_disconnections: false,
autoreload: false,