Skip to content

Commit ba5243b

Browse files
authored
Optionally validate config on boot (#423)
1 parent 128ef72 commit ba5243b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ pub struct General {
298298
pub admin_username: String,
299299
pub admin_password: String,
300300

301+
#[serde(default = "General::default_validate_config")]
302+
pub validate_config: bool,
303+
301304
// Support for auth query
302305
pub auth_query: Option<String>,
303306
pub auth_query_user: Option<String>,
@@ -367,6 +370,10 @@ impl General {
367370
pub fn default_idle_client_in_transaction_timeout() -> u64 {
368371
0
369372
}
373+
374+
pub fn default_validate_config() -> bool {
375+
true
376+
}
370377
}
371378

372379
impl Default for General {
@@ -402,6 +409,7 @@ impl Default for General {
402409
auth_query_user: None,
403410
auth_query_password: None,
404411
server_lifetime: 1000 * 3600 * 24, // 24 hours,
412+
validate_config: true,
405413
}
406414
}
407415
}

src/pool.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,12 @@ impl ConnectionPool {
459459
// Connect to the servers to make sure pool configuration is valid
460460
// before setting it globally.
461461
// Do this async and somewhere else, we don't have to wait here.
462-
let mut validate_pool = pool.clone();
463-
tokio::task::spawn(async move {
464-
let _ = validate_pool.validate().await;
465-
});
462+
if config.general.validate_config {
463+
let mut validate_pool = pool.clone();
464+
tokio::task::spawn(async move {
465+
let _ = validate_pool.validate().await;
466+
});
467+
}
466468

467469
// There is one pool per database/user pair.
468470
new_pools.insert(PoolIdentifier::new(pool_name, &user.username), pool);

0 commit comments

Comments
 (0)