[−][src]Struct orma_mobc::PgConnectionManager
A mobc::Manager
for orma::Connection
s.
This crate is a strict derivation of mobc-postgres
Example
use mobc::Pool; use orma_mobc::PgConnectionManager; use orma::{Config, NoTls}; use std::time::Instant; use std::str::FromStr; #[tokio::main] async fn main() { let config = Config::from_str("postgres://user:passwd@localhost:5432").unwrap(); let manager = PgConnectionManager::new(config, NoTls); let pool = Pool::builder().max_open(20).build(manager); const MAX: usize = 5000; let now = Instant::now(); let (tx, mut rx) = tokio::sync::mpsc::channel::<usize>(16); for i in 0..MAX { let pool = pool.clone(); let mut tx_c = tx.clone(); tokio::spawn(async move { let connection = pool.get().await.unwrap(); let rows = connection.query("SELECT 1 + 2", &[]).await.unwrap(); let value: i32 = rows[0].get(0); assert_eq!(value, 3); tx_c.send(i).await.unwrap(); }); } for _ in 0..MAX { rx.recv().await.unwrap(); } println!("cost: {:?}", now.elapsed()); }
Implementations
impl<Tls> PgConnectionManager<Tls>
[src]
Trait Implementations
impl<Tls> Manager for PgConnectionManager<Tls> where
Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static,
<Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
<Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
<<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
[src]
Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static,
<Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
<Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
<<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
type Connection = Connection
The connection type this manager deals with.
type Error = DbError
The error type returned by Connection
s.
fn connect<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn check<'life0, 'async_trait>(
&'life0 self,
conn: Self::Connection
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
conn: Self::Connection
) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn spawn_task<T>(&self, task: T) where
T: Future + Send + 'static,
<T as Future>::Output: Send,
<T as Future>::Output: 'static,
[src]
T: Future + Send + 'static,
<T as Future>::Output: Send,
<T as Future>::Output: 'static,
Auto Trait Implementations
impl<Tls> RefUnwindSafe for PgConnectionManager<Tls> where
Tls: RefUnwindSafe,
Tls: RefUnwindSafe,
impl<Tls> Send for PgConnectionManager<Tls> where
Tls: Send,
Tls: Send,
impl<Tls> Sync for PgConnectionManager<Tls> where
Tls: Sync,
Tls: Sync,
impl<Tls> Unpin for PgConnectionManager<Tls> where
Tls: Unpin,
Tls: Unpin,
impl<Tls> UnwindSafe for PgConnectionManager<Tls> where
Tls: UnwindSafe,
Tls: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,