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.

See Connection Parameters.

connection: Option<ConnectionInfo>pool: Option<PoolConfig>

Pool configuration.

Implementations

Creates a new Pool using this Config.

Errors

See CreatePoolError for details.

Creates a new PoolBuilder using this Config.

Errors

See ConfigError for details.

Returns deadpool::managed::PoolConfig which can be used to construct a deadpool::managed::Pool instance.

Creates a new Config from the given Redis URL (like redis://127.0.0.1).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more