mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-27 18:56:30 +00:00
Optionally validate config on boot (#423)
This commit is contained in:
@@ -298,6 +298,9 @@ pub struct General {
|
|||||||
pub admin_username: String,
|
pub admin_username: String,
|
||||||
pub admin_password: String,
|
pub admin_password: String,
|
||||||
|
|
||||||
|
#[serde(default = "General::default_validate_config")]
|
||||||
|
pub validate_config: bool,
|
||||||
|
|
||||||
// Support for auth query
|
// Support for auth query
|
||||||
pub auth_query: Option<String>,
|
pub auth_query: Option<String>,
|
||||||
pub auth_query_user: Option<String>,
|
pub auth_query_user: Option<String>,
|
||||||
@@ -367,6 +370,10 @@ impl General {
|
|||||||
pub fn default_idle_client_in_transaction_timeout() -> u64 {
|
pub fn default_idle_client_in_transaction_timeout() -> u64 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_validate_config() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for General {
|
impl Default for General {
|
||||||
@@ -402,6 +409,7 @@ impl Default for General {
|
|||||||
auth_query_user: None,
|
auth_query_user: None,
|
||||||
auth_query_password: None,
|
auth_query_password: None,
|
||||||
server_lifetime: 1000 * 3600 * 24, // 24 hours,
|
server_lifetime: 1000 * 3600 * 24, // 24 hours,
|
||||||
|
validate_config: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/pool.rs
10
src/pool.rs
@@ -459,10 +459,12 @@ impl ConnectionPool {
|
|||||||
// Connect to the servers to make sure pool configuration is valid
|
// Connect to the servers to make sure pool configuration is valid
|
||||||
// before setting it globally.
|
// before setting it globally.
|
||||||
// Do this async and somewhere else, we don't have to wait here.
|
// Do this async and somewhere else, we don't have to wait here.
|
||||||
let mut validate_pool = pool.clone();
|
if config.general.validate_config {
|
||||||
tokio::task::spawn(async move {
|
let mut validate_pool = pool.clone();
|
||||||
let _ = validate_pool.validate().await;
|
tokio::task::spawn(async move {
|
||||||
});
|
let _ = validate_pool.validate().await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// There is one pool per database/user pair.
|
// There is one pool per database/user pair.
|
||||||
new_pools.insert(PoolIdentifier::new(pool_name, &user.username), pool);
|
new_pools.insert(PoolIdentifier::new(pool_name, &user.username), pool);
|
||||||
|
|||||||
Reference in New Issue
Block a user