Skip to content

Commit

Permalink
build(deps): use async-bb8-diesel from crates.io instead of git r…
Browse files Browse the repository at this point in the history
…epository (#2619)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Chethan-rao and github-actions[bot] authored Oct 19, 2023
1 parent 7e6207e commit 14c0821
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/diesel_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kv_store = []
s3 = ["dep:aws-sdk-s3", "dep:aws-config"]

[dependencies]
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
async-bb8-diesel = "0.1.0"
aws-config = { version = "0.55.3", optional = true }
aws-sdk-s3 = { version = "0.28.0", optional = true }
diesel = { version = "2.1.0", features = ["postgres", "serde_json", "time", "64-column-tables"] }
Expand Down
33 changes: 12 additions & 21 deletions crates/diesel_models/src/query/generics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Debug;

use async_bb8_diesel::{AsyncRunQueryDsl, ConnectionError};
use async_bb8_diesel::AsyncRunQueryDsl;
use diesel::{
associations::HasTable,
debug_query,
Expand Down Expand Up @@ -93,10 +93,9 @@ where
{
Ok(value) => Ok(value),
Err(err) => match err.current_context() {
ConnectionError::Query(DieselError::DatabaseError(
diesel::result::DatabaseErrorKind::UniqueViolation,
_,
)) => Err(err).change_context(errors::DatabaseError::UniqueViolation),
DieselError::DatabaseError(diesel::result::DatabaseErrorKind::UniqueViolation, _) => {
Err(err).change_context(errors::DatabaseError::UniqueViolation)
}
_ => Err(err).change_context(errors::DatabaseError::Others),
},
}
Expand Down Expand Up @@ -168,14 +167,12 @@ where
logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
Ok(result)
}
Err(ConnectionError::Query(DieselError::QueryBuilderError(_))) => {
Err(DieselError::QueryBuilderError(_)) => {
Err(report!(errors::DatabaseError::NoFieldsToUpdate))
.attach_printable_lazy(|| format!("Error while updating {debug_values}"))
}
Err(ConnectionError::Query(DieselError::NotFound)) => {
Err(report!(errors::DatabaseError::NotFound))
.attach_printable_lazy(|| format!("Error while updating {debug_values}"))
}
Err(DieselError::NotFound) => Err(report!(errors::DatabaseError::NotFound))
.attach_printable_lazy(|| format!("Error while updating {debug_values}")),
_ => Err(report!(errors::DatabaseError::Others))
.attach_printable_lazy(|| format!("Error while updating {debug_values}")),
}
Expand Down Expand Up @@ -259,14 +256,12 @@ where
logger::debug!(query = %debug_query::<Pg, _>(&query).to_string());
Ok(result)
}
Err(ConnectionError::Query(DieselError::QueryBuilderError(_))) => {
Err(DieselError::QueryBuilderError(_)) => {
Err(report!(errors::DatabaseError::NoFieldsToUpdate))
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}"))
}
Err(ConnectionError::Query(DieselError::NotFound)) => {
Err(report!(errors::DatabaseError::NotFound))
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}"))
}
Err(DieselError::NotFound) => Err(report!(errors::DatabaseError::NotFound))
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}")),
_ => Err(report!(errors::DatabaseError::Others))
.attach_printable_lazy(|| format!("Error while updating by ID {debug_values}")),
}
Expand Down Expand Up @@ -353,9 +348,7 @@ where
{
Ok(value) => Ok(value),
Err(err) => match err.current_context() {
ConnectionError::Query(DieselError::NotFound) => {
Err(err).change_context(errors::DatabaseError::NotFound)
}
DieselError::NotFound => Err(err).change_context(errors::DatabaseError::NotFound),
_ => Err(err).change_context(errors::DatabaseError::Others),
},
}
Expand Down Expand Up @@ -404,9 +397,7 @@ where
.await
.into_report()
.map_err(|err| match err.current_context() {
ConnectionError::Query(DieselError::NotFound) => {
err.change_context(errors::DatabaseError::NotFound)
}
DieselError::NotFound => err.change_context(errors::DatabaseError::NotFound),
_ => err.change_context(errors::DatabaseError::Others),
})
.attach_printable_lazy(|| "Error finding record by predicate")
Expand Down
2 changes: 1 addition & 1 deletion crates/drainer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kms = ["external_services/kms"]
vergen = ["router_env/vergen"]

[dependencies]
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
async-bb8-diesel = "0.1.0"
bb8 = "0.8"
clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage"] }
config = { version = "0.13.3", features = ["toml"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ actix-cors = "0.6.4"
actix-multipart = "0.6.0"
actix-rt = "2.8.0"
actix-web = "4.3.1"
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
async-bb8-diesel = "0.1.0"
async-trait = "0.1.68"
aws-config = { version = "0.55.3", optional = true }
aws-sdk-s3 = { version = "0.28.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/storage_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ router_derive = { version = "0.1.0", path = "../router_derive" }

# Third party crates
actix-web = "4.3.1"
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "be3d9bce50051d8c0e0c06078e8066cc27db3001" }
async-bb8-diesel = "0.1.0"
async-trait = "0.1.72"
bb8 = "0.8.1"
bytes = "1.4.0"
Expand Down
17 changes: 13 additions & 4 deletions crates/storage_impl/src/payments/payment_intent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(feature = "olap")]
use async_bb8_diesel::AsyncRunQueryDsl;
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::{date_time, ext_traits::Encode};
#[cfg(feature = "olap")]
use data_models::payments::payment_intent::PaymentIntentFetchConstraints;
Expand Down Expand Up @@ -34,6 +34,8 @@ use redis_interface::HsetnxReply;
use router_env::logger;
use router_env::{instrument, tracing};

#[cfg(feature = "olap")]
use crate::connection;
use crate::{
diesel_error_to_data_error,
redis::kv_store::{kv_wrapper, KvOperation},
Expand Down Expand Up @@ -387,7 +389,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
filters: &PaymentIntentFetchConstraints,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentIntent>, StorageError> {
let conn = self.get_replica_pool();
use common_utils::errors::ReportSwitchExt;

let conn = connection::pg_connection_read(self).await.switch()?;
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);

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

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

let conn = connection::pg_connection_read(self).await.switch()?;
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);
let mut query = DieselPaymentIntent::table()
.select(pi_dsl::active_attempt_id)
.filter(pi_dsl::merchant_id.eq(merchant_id.to_owned()))
Expand Down

0 comments on commit 14c0821

Please sign in to comment.