relay_redis/config.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
use serde::{Deserialize, Serialize};
/// Additional configuration options for a redis client.
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct RedisConfigOptions {
/// Maximum number of connections managed by the pool.
pub max_connections: u32,
/// Minimum amount of idle connections kept alive in the pool.
///
/// If not set it will default to [`Self::max_connections`].
pub min_idle: Option<u32>,
/// Sets the connection timeout used by the pool, in seconds.
///
/// Calls to `Pool::get` will wait this long for a connection to become available before returning an error.
pub connection_timeout: u64,
/// Sets the maximum lifetime of connections in the pool, in seconds.
pub max_lifetime: u64,
/// Sets the idle timeout used by the pool, in seconds.
pub idle_timeout: u64,
/// Sets the read timeout out on the connection, in seconds.
pub read_timeout: u64,
/// Sets the write timeout on the connection, in seconds.
pub write_timeout: u64,
}
impl Default for RedisConfigOptions {
fn default() -> Self {
Self {
max_connections: 24,
min_idle: None,
connection_timeout: 5,
max_lifetime: 300,
idle_timeout: 60,
read_timeout: 3,
write_timeout: 3,
}
}
}