use std::time::Duration;
#[derive(Clone, Debug)]
pub struct RedisLockStoreConfig {
pub url: String,
pub prefix: String,
pub pool_max_size: u32,
pub connection_timeout: Duration,
pub warm_pool: bool,
}
impl RedisLockStoreConfig {
#[must_use]
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
prefix: "serenade:lock:".to_owned(),
pool_max_size: 8,
connection_timeout: Duration::from_secs(2),
warm_pool: false,
}
}
#[must_use]
pub fn with_prefix(mut self, prefix: impl Into<String>) -> Self {
self.prefix = prefix.into();
self
}
#[must_use]
pub fn with_pool_max_size(mut self, pool_max_size: u32) -> Self {
self.pool_max_size = pool_max_size.max(1);
self
}
#[must_use]
pub const fn with_connection_timeout(mut self, connection_timeout: Duration) -> Self {
self.connection_timeout = connection_timeout;
self
}
#[must_use]
pub const fn with_warm_pool(mut self, warm_pool: bool) -> Self {
self.warm_pool = warm_pool;
self
}
}