Struct deadpool_postgres::config::Config [−][src]
pub struct Config {}Show fields
pub user: Option<String>, pub password: Option<String>, pub dbname: Option<String>, pub options: Option<String>, pub application_name: Option<String>, pub ssl_mode: Option<SslMode>, pub host: Option<String>, pub hosts: Option<Vec<String>>, pub port: Option<u16>, pub ports: Option<Vec<u16>>, pub connect_timeout: Option<Duration>, pub keepalives: Option<bool>, pub keepalives_idle: Option<Duration>, pub target_session_attrs: Option<TargetSessionAttrs>, pub channel_binding: Option<ChannelBinding>, pub manager: Option<ManagerConfig>, pub pool: Option<PoolConfig>,
Expand description
Configuration object. By enabling the config
feature you can
read the configuration using the config
crate.
Example environment
PG__HOST=pg.example.com
PG__USER=john_doe
PG__PASSWORD=topsecret
PG__DBNAME=example
PG__POOL__MAX_SIZE=16
PG__POOL__TIMEOUTS__WAIT__SECS=5
PG__POOL__TIMEOUTS__WAIT__NANOS=0
Example usage
struct Config { pg: deadpool_postgres::Config, } impl Config { pub fn from_env() -> Result<Self, ConfigError> { let mut cfg = config::Config::new(); cfg.merge(config::Environment::new().separator("__")).unwrap(); cfg.try_into().unwrap() } }
Fields
user: Option<String>
See tokio_postgres::Config::user
password: Option<String>
See tokio_postgres::Config::password
dbname: Option<String>
See tokio_postgres::Config::dbname
options: Option<String>
See tokio_postgres::Config::options
application_name: Option<String>
See tokio_postgres::Config::application_name
ssl_mode: Option<SslMode>
See tokio_postgres::Config::ssl_mode
host: Option<String>
This is similar to hosts
but only allows one host to be specified.
Unlike tokio-postgres::Config
this structure differenciates between
one host and more than one host. This makes it possible to store this
configuration in an envorinment variable.
See tokio_postgres::Config::host
hosts: Option<Vec<String>>
See tokio_postgres::Config::hosts
port: Option<u16>
This is similar to ports
but only allows one port to be specified.
Unlike tokio-postgres::Config
this structure differenciates between
one port and more than one port. This makes it possible to store this
configuration in an environment variable.
See tokio_postgres::Config::port
ports: Option<Vec<u16>>
See tokio_postgres::Config::port
connect_timeout: Option<Duration>
See tokio_postgres::Config::connect_timeout
keepalives: Option<bool>
See tokio_postgres::Config::keepalives
keepalives_idle: Option<Duration>
See tokio_postgres::Config::keepalives_idle
target_session_attrs: Option<TargetSessionAttrs>
See tokio_postgres::Config::target_session_attrs
channel_binding: Option<ChannelBinding>
See tokio_postgres::Config::channel_binding
manager: Option<ManagerConfig>
Manager configuration
pool: Option<PoolConfig>
Pool configuration
Implementations
impl Config
[src]
impl Config
[src]pub fn new() -> Self
[src]
pub fn new() -> Self
[src]Create new config instance with default values. This function is
identical to Config::default
.
pub fn create_pool<T: MakeTlsConnect<Socket>>(
&self,
tls: T
) -> Result<Pool, ConfigError> where
T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,
T::Stream: Sync + Send,
T::TlsConnect: Sync + Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
[src]
pub fn create_pool<T: MakeTlsConnect<Socket>>(
&self,
tls: T
) -> Result<Pool, ConfigError> where
T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,
T::Stream: Sync + Send,
T::TlsConnect: Sync + Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
[src]Create pool using the current configuration
pub fn get_pg_config(&self) -> Result<Config, ConfigError>
[src]
pub fn get_pg_config(&self) -> Result<Config, ConfigError>
[src]Get tokio_postgres::Config
which can be used to connect to
the database.
pub fn get_manager_config(&self) -> ManagerConfig
[src]
pub fn get_manager_config(&self) -> ManagerConfig
[src]Get deadpool_postgres::ManagerConfig
which can be used to
construct a deadpool::managed::Pool
instance.
pub fn get_pool_config(&self) -> PoolConfig
[src]
pub fn get_pool_config(&self) -> PoolConfig
[src]Get deadpool::PoolConfig
which can be used to construct a
deadpool::managed::Pool
instance.
Trait Implementations
impl<'de> Deserialize<'de> for Config
[src]
impl<'de> Deserialize<'de> for Config
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,