Skip to content

Commit b3abd15

Browse files
authored
Bump Diesel and bb8 to match v-api (#92)
* bumped diesel version * update bb8 to be inline with v-api * fix CustomizeConnection example for bb8 0.9 * Use explicit lifetimes with Pin<Box<dyn Future>> instead of async_trait macro to match bb8 0.9's trait signature.
1 parent 1403df2 commit b3abd15

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ cockroach = []
1414
default = [ "cockroach" ]
1515

1616
[dependencies]
17-
bb8 = "0.8"
17+
bb8 = "0.9"
1818
async-trait = "0.1.89"
19-
diesel = { version = "2.3.4", default-features = false, features = [ "r2d2" ] }
19+
diesel = { version = "2.3.5", default-features = false, features = [ "r2d2" ] }
2020
futures = "0.3"
2121
thiserror = "2.0"
2222
tokio = { version = "1.32", default-features = false, features = [ "rt-multi-thread" ] }
2323

2424
[dev-dependencies]
2525
anyhow = "1.0"
2626
crdb-harness = "0.0.2"
27-
diesel = { version = "2.3.4", features = [ "postgres", "r2d2" ] }
27+
diesel = { version = "2.3.5", features = [ "postgres", "r2d2" ] }
2828
libc = "0.2.178"
2929
tempfile = "3.8"
3030
tokio = { version = "1.32", features = [ "macros", "fs", "process" ] }

examples/customize_connection.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
//! An example showing how to cutomize connections while using pooling.
22
33
use async_bb8_diesel::{AsyncSimpleConnection, Connection, ConnectionError};
4-
use async_trait::async_trait;
54
use diesel::pg::PgConnection;
5+
use std::future::Future;
6+
use std::pin::Pin;
67

78
#[derive(Debug)]
89
struct ConnectionCustomizer {}
910

1011
type DieselPgConn = Connection<PgConnection>;
1112

12-
#[async_trait]
1313
impl bb8::CustomizeConnection<DieselPgConn, ConnectionError> for ConnectionCustomizer {
14-
async fn on_acquire(&self, connection: &mut DieselPgConn) -> Result<(), ConnectionError> {
15-
connection
16-
.batch_execute_async("please execute some raw sql for me")
17-
.await
18-
.map_err(ConnectionError::from)
14+
fn on_acquire<'a>(
15+
&'a self,
16+
connection: &'a mut DieselPgConn,
17+
) -> Pin<Box<dyn Future<Output = Result<(), ConnectionError>> + Send + 'a>> {
18+
Box::pin(async move {
19+
connection
20+
.batch_execute_async("please execute some raw sql for me")
21+
.await
22+
.map_err(ConnectionError::from)
23+
})
1924
}
2025
}
2126

src/connection_manager.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! An async-safe connection pool for Diesel.
22
33
use crate::{Connection, ConnectionError};
4-
use async_trait::async_trait;
54
use diesel::r2d2::{self, ManageConnection, R2D2Connection};
65
use std::sync::{Arc, Mutex};
76

@@ -59,7 +58,6 @@ impl<T: Send + 'static> ConnectionManager<T> {
5958
}
6059
}
6160

62-
#[async_trait]
6361
impl<T> bb8::ManageConnection for ConnectionManager<T>
6462
where
6563
T: R2D2Connection + Send + 'static,

0 commit comments

Comments
 (0)