pub struct Config {
pub url: Option<String>,
pub pool: Option<PoolConfig>,
pub connection_properties: ConnectionProperties,
}Expand description
Configuration object.
§Example (from environment)
By enabling the serde feature you can read the configuration using the
config crate as following:
AMQP__URL=amqp://127.0.0.1:5672/%2f
AMQP__POOL__MAX_SIZE=16
AMQP__POOL__TIMEOUTS__WAIT__SECS=2
AMQP__POOL__TIMEOUTS__WAIT__NANOS=0#[derive(serde::Deserialize)]
struct Config {
amqp: deadpool_lapin::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>AMQP server URL.
pool: Option<PoolConfig>Pool configuration.
connection_properties: ConnectionPropertiesConnection properties.
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, runtime: Option<Runtime>) -> PoolBuilder
pub fn builder(&self, runtime: Option<Runtime>) -> PoolBuilder
Creates a new PoolBuilder using this Config.
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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