Skip to content

Commit 14c0821

Browse files
build(deps): use async-bb8-diesel from crates.io instead of git repository (#2619)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7e6207e commit 14c0821

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/diesel_models/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ kv_store = []
1515
s3 = ["dep:aws-sdk-s3", "dep:aws-config"]
1616

1717
[dependencies]
18-
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
18+
async-bb8-diesel = "0.1.0"
1919
aws-config = { version = "0.55.3", optional = true }
2020
aws-sdk-s3 = { version = "0.28.0", optional = true }
2121
diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time", "64-column-tables"] }

crates/diesel_models/src/query/generics.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt::Debug;
22

3-
use async_bb8_diesel::{AsyncRunQueryDsl, ConnectionError};
3+
use async_bb8_diesel::AsyncRunQueryDsl;
44
use diesel::{
55
associations::HasTable,
66
debug_query,
@@ -93,10 +93,9 @@ where
9393
{
9494
Ok(value) => Ok(value),
9595
Err(err) => match err.current_context() {
96-
ConnectionError::Query(DieselError::DatabaseError(
97-
diesel::result::DatabaseErrorKind::UniqueViolation,
98-
_,
99-
)) => Err(err).change_context(errors::DatabaseError::UniqueViolation),
96+
DieselError::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _) => {
97+
Err(err).change_context(errors::DatabaseError::UniqueViolation)
98+
}
10099
_ => Err(err).change_context(errors::DatabaseError::Others),
101100
},
102101
}
@@ -168,14 +167,12 @@ where
168167
logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
169168
Ok(result)
170169
}
171-
Err(ConnectionError::Query(DieselError::QueryBuilderError(_))) => {
170+
Err(DieselError::QueryBuilderError(_)) => {
172171
Err(report!(errors::DatabaseError::NoFieldsToUpdate))
173172
.attach_printable_lazy(|| format!("Error while updating {debug_values}"))
174173
}
175-
Err(ConnectionError::Query(DieselError::NotFound)) => {
176-
Err(report!(errors::DatabaseError::NotFound))
177-
.attach_printable_lazy(|| format!("Error while updating {debug_values}"))
178-
}
174+
Err(DieselError::NotFound) => Err(report!(errors::DatabaseError::NotFound))
175+
.attach_printable_lazy(|| format!("Error while updating {debug_values}")),
179176
_ => Err(report!(errors::DatabaseError::Others))
180177
.attach_printable_lazy(|| format!("Error while updating {debug_values}")),
181178
}
@@ -259,14 +256,12 @@ where
259256
logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
260257
Ok(result)
261258
}
262-
Err(ConnectionError::Query(DieselError::QueryBuilderError(_))) => {
259+
Err(DieselError::QueryBuilderError(_)) => {
263260
Err(report!(errors::DatabaseError::NoFieldsToUpdate))
264261
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}"))
265262
}
266-
Err(ConnectionError::Query(DieselError::NotFound)) => {
267-
Err(report!(errors::DatabaseError::NotFound))
268-
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}"))
269-
}
263+
Err(DieselError::NotFound) => Err(report!(errors::DatabaseError::NotFound))
264+
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}")),
270265
_ => Err(report!(errors::DatabaseError::Others))
271266
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}")),
272267
}
@@ -353,9 +348,7 @@ where
353348
{
354349
Ok(value) => Ok(value),
355350
Err(err) => match err.current_context() {
356-
ConnectionError::Query(DieselError::NotFound) => {
357-
Err(err).change_context(errors::DatabaseError::NotFound)
358-
}
351+
DieselError::NotFound => Err(err).change_context(errors::DatabaseError::NotFound),
359352
_ => Err(err).change_context(errors::DatabaseError::Others),
360353
},
361354
}
@@ -404,9 +397,7 @@ where
404397
.await
405398
.into_report()
406399
.map_err(|err| match err.current_context() {
407-
ConnectionError::Query(DieselError::NotFound) => {
408-
err.change_context(errors::DatabaseError::NotFound)
409-
}
400+
DieselError::NotFound => err.change_context(errors::DatabaseError::NotFound),
410401
_ => err.change_context(errors::DatabaseError::Others),
411402
})
412403
.attach_printable_lazy(|| "Error finding record by predicate")

crates/drainer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ kms = ["external_services/kms"]
1313
vergen = ["router_env/vergen"]
1414

1515
[dependencies]
16-
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
16+
async-bb8-diesel = "0.1.0"
1717
bb8 = "0.8"
1818
clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] }
1919
config = { version = "0.13.3", features = ["toml"] }

crates/router/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ actix-cors = "0.6.4"
3535
actix-multipart = "0.6.0"
3636
actix-rt = "2.8.0"
3737
actix-web = "4.3.1"
38-
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
38+
async-bb8-diesel = "0.1.0"
3939
async-trait = "0.1.68"
4040
aws-config = { version = "0.55.3", optional = true }
4141
aws-sdk-s3 = { version = "0.28.0", optional = true }

crates/storage_impl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ router_derive = { version = "0.1.0", path = "../router_derive" }
2828

2929
# Third party crates
3030
actix-web = "4.3.1"
31-
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
31+
async-bb8-diesel = "0.1.0"
3232
async-trait = "0.1.72"
3333
bb8 = "0.8.1"
3434
bytes = "1.4.0"

crates/storage_impl/src/payments/payment_intent.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[cfg(feature = "olap")]
2-
use async_bb8_diesel::AsyncRunQueryDsl;
2+
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
33
use common_utils::{date_time, ext_traits::Encode};
44
#[cfg(feature = "olap")]
55
use data_models::payments::payment_intent::PaymentIntentFetchConstraints;
@@ -34,6 +34,8 @@ use redis_interface::HsetnxReply;
3434
use router_env::logger;
3535
use router_env::{instrument, tracing};
3636

37+
#[cfg(feature = "olap")]
38+
use crate::connection;
3739
use crate::{
3840
diesel_error_to_data_error,
3941
redis::kv_store::{kv_wrapper, KvOperation},
@@ -387,7 +389,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
387389
filters: &PaymentIntentFetchConstraints,
388390
storage_scheme: MerchantStorageScheme,
389391
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
390-
let conn = self.get_replica_pool();
392+
use common_utils::errors::ReportSwitchExt;
393+
394+
let conn = connection::pg_connection_read(self).await.switch()?;
395+
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);
391396

392397
//[#350]: Replace this with Boxable Expression and pass it into generic filter
393398
// when https://github.com/rust-lang/rust/issues/52662 becomes stable
@@ -509,8 +514,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
509514
constraints: &PaymentIntentFetchConstraints,
510515
storage_scheme: MerchantStorageScheme,
511516
) -> error_stack::Result<Vec<(PaymentIntent, PaymentAttempt)>, StorageError> {
512-
let conn = self.get_replica_pool();
517+
use common_utils::errors::ReportSwitchExt;
513518

519+
let conn = connection::pg_connection_read(self).await.switch()?;
520+
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);
514521
let mut query = DieselPaymentIntent::table()
515522
.inner_join(
516523
diesel_models::schema::payment_attempt::table
@@ -646,8 +653,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
646653
constraints: &PaymentIntentFetchConstraints,
647654
_storage_scheme: MerchantStorageScheme,
648655
) -> error_stack::Result<Vec<String>, StorageError> {
649-
let conn = self.get_replica_pool();
656+
use common_utils::errors::ReportSwitchExt;
650657

658+
let conn = connection::pg_connection_read(self).await.switch()?;
659+
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);
651660
let mut query = DieselPaymentIntent::table()
652661
.select(pi_dsl::active_attempt_id)
653662
.filter(pi_dsl::merchant_id.eq(merchant_id.to_owned()))

0 commit comments

Comments
 (0)