Skip to content

Commit

Permalink
Update bb8 to 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Dec 9, 2024
1 parent 9390053 commit 888b65d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cockroach = []
default = [ "cockroach" ]

[dependencies]
bb8 = "0.8"
bb8 = "0.9"
async-trait = "0.1.81"
diesel = { version = "2.2.2", default-features = false, features = [ "r2d2" ] }
futures = "0.3"
Expand Down
17 changes: 10 additions & 7 deletions examples/customize_connection.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
//! An example showing how to cutomize connections while using pooling.
use std::future::Future;
use std::pin::Pin;

use async_bb8_diesel::{AsyncSimpleConnection, Connection, ConnectionError};
use async_trait::async_trait;
use diesel::pg::PgConnection;

#[derive(Debug)]
struct ConnectionCustomizer {}

type DieselPgConn = Connection<PgConnection>;

#[async_trait]
impl bb8::CustomizeConnection<DieselPgConn, ConnectionError> for ConnectionCustomizer {
async fn on_acquire(&self, connection: &mut DieselPgConn) -> Result<(), ConnectionError> {
connection
.batch_execute_async("please execute some raw sql for me")
.await
.map_err(ConnectionError::from)
fn on_acquire<'a>(&'a self, connection: &'a mut DieselPgConn) -> Pin<Box<dyn Future<Output = Result<(), ConnectionError>> + Send + 'a>> {
Box::pin(async move {
let res = connection
.batch_execute_async("please execute some raw sql for me")
.await;
res.map_err(ConnectionError::from)
})
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/connection_manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! An async-safe connection pool for Diesel.
use crate::{Connection, ConnectionError};
use async_trait::async_trait;
use diesel::r2d2::{self, ManageConnection, R2D2Connection};
use std::sync::{Arc, Mutex};

Expand Down Expand Up @@ -59,7 +58,6 @@ impl<T: Send + 'static> ConnectionManager<T> {
}
}

#[async_trait]
impl<T> bb8::ManageConnection for ConnectionManager<T>
where
T: R2D2Connection + Send + 'static,
Expand Down

0 comments on commit 888b65d

Please sign in to comment.