Struct deadpool_redis::sentinel::Config
source · pub struct Config {
pub urls: Option<Vec<String>>,
pub server_type: SentinelServerType,
pub master_name: String,
pub connections: Option<Vec<ConnectionInfo>>,
pub pool: Option<PoolConfig>,
/* private fields */
}
Expand description
Configuration object.
§Example (from environment)
By enabling the serde
feature you can read the configuration using the
config
crate as following:
REDIS_SENTINEL__URLS=redis://127.0.0.1:26379,redis://127.0.0.1:26380
REDIS_SENTINEL__MASTER_NAME=mymaster
REDIS_SENTINEL__SERVER_TYPE=master
REDIS_SENTINEL__POOL__MAX_SIZE=16
REDIS_SENTINEL__POOL__TIMEOUTS__WAIT__SECS=2
REDIS_SENTINEL__POOL__TIMEOUTS__WAIT__NANOS=0
#[derive(serde::Deserialize)]
struct Config {
redis_sentinel: deadpool_redis::sentinel::Config,
}
impl Config {
pub fn from_env() -> Result<Self, config::ConfigError> {
let mut cfg = config::Config::builder()
.add_source(
config::Environment::default()
.separator("__")
.try_parsing(true)
.list_separator(","),
)
.build()?;
cfg.try_deserialize()
}
}
Fields§
§urls: Option<Vec<String>>
Redis URLs.
server_type: SentinelServerType
ServerType
master_name: String
Sentinel setup master name. default value is mymaster
connections: Option<Vec<ConnectionInfo>>
redis::ConnectionInfo
structures.
pool: Option<PoolConfig>
Pool configuration.
Implementations§
source§impl Config
impl Config
sourcepub fn create_pool(
&self,
runtime: Option<Runtime>,
) -> Result<Pool, CreatePoolError>
pub fn create_pool( &self, runtime: Option<Runtime>, ) -> Result<Pool, CreatePoolError>
sourcepub fn builder(&self) -> Result<PoolBuilder, ConfigError>
pub fn builder(&self) -> Result<PoolBuilder, ConfigError>
sourcepub fn get_pool_config(&self) -> PoolConfig
pub fn get_pool_config(&self) -> PoolConfig
Returns deadpool::managed::PoolConfig
which can be used to construct
a deadpool::managed::Pool
instance.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)