Add defaults for configs (#174)

* add statement timeout to readme

* Add defaults to various configs

* primary read enabled default to false
This commit is contained in:
zainkabani
2022-09-23 02:00:46 -04:00
committed by GitHub
parent 3a729bb75b
commit f72dac420b
5 changed files with 115 additions and 58 deletions

View File

@@ -12,7 +12,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::time::Instant;
use crate::config::{get_config, Address, Role, User};
use crate::config::{get_config, Address, PoolMode, Role, User};
use crate::errors::Error;
use crate::server::Server;
@@ -27,24 +27,6 @@ pub type PoolMap = HashMap<(String, String), ConnectionPool>;
/// The pool is recreated dynamically when the config is reloaded.
pub static POOLS: Lazy<ArcSwap<PoolMap>> = Lazy::new(|| ArcSwap::from_pointee(HashMap::default()));
/// Pool mode:
/// - transaction: server serves one transaction,
/// - session: server is attached to the client.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PoolMode {
Session,
Transaction,
}
impl std::fmt::Display for PoolMode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
PoolMode::Session => write!(f, "session"),
PoolMode::Transaction => write!(f, "transaction"),
}
}
}
/// Pool settings.
#[derive(Clone, Debug)]
pub struct PoolSettings {
@@ -199,11 +181,7 @@ impl ConnectionPool {
stats: get_reporter(),
server_info: BytesMut::new(),
settings: PoolSettings {
pool_mode: match pool_config.pool_mode.as_str() {
"transaction" => PoolMode::Transaction,
"session" => PoolMode::Session,
_ => unreachable!(),
},
pool_mode: pool_config.pool_mode,
// shards: pool_config.shards.clone(),
shards: shard_ids.len(),
user: user.clone(),