Struct deadpool_redis::Config
source · pub struct Config {
pub url: Option<String>,
pub connection: Option<ConnectionInfo>,
pub pool: Option<PoolConfig>,
}
Expand description
Configuration object.
Example (from environment)
By enabling the serde
feature you can read the configuration using the
config
crate as following:
REDIS__CONNECTION__ADDR=redis.example.com
REDIS__POOL__MAX_SIZE=16
REDIS__POOL__TIMEOUTS__WAIT__SECS=2
REDIS__POOL__TIMEOUTS__WAIT__NANOS=0
#[derive(serde::Deserialize)]
struct Config {
redis: deadpool_redis::Config,
}
impl Config {
pub fn from_env() -> Result<Self, config::ConfigError> {
let mut cfg = config::Config::builder()
.add_source(config::Environment::default().separator("__"))
.build()?;
cfg.try_deserialize()
}
}
Fields§
§url: Option<String>
Redis URL.
connection: Option<ConnectionInfo>
redis::ConnectionInfo
structure.
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.
sourcepub fn from_url<T: Into<String>>(url: T) -> Config
pub fn from_url<T: Into<String>>(url: T) -> Config
Creates a new Config
from the given Redis URL (like
redis://127.0.0.1
).
sourcepub fn from_connection_info<T: Into<ConnectionInfo>>(
connection_info: T
) -> Config
pub fn from_connection_info<T: Into<ConnectionInfo>>(
connection_info: T
) -> Config
Creates a new Config
from the given Redis ConnectionInfo
structure.
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