Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ jobs:
- name: Cargo check
run: cargo check --no-default-features

build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-12 ]
build-and-test-macos-14:
runs-on: macos-14
steps:
# actions/checkout@v2
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Link libpq
run: brew link --force libpq
- name: Build
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose

build-and-test-ubuntu:
runs-on: ubuntu-latest
steps:
# actions/checkout@v2
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
Expand Down
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
20 changes: 13 additions & 7 deletions examples/customize_connection.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
//! 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
Loading