From f9af11e4c56ab6b8c79bdfbe5d2d2e4b68246570 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:16:34 +0000 Subject: [PATCH] chore: run formatter --- .../src/payment_methods.rs | 26 ++++++------ crates/payment_methods/src/client.rs | 3 +- crates/router/src/configs/settings.rs | 4 +- crates/router/src/routes/app.rs | 5 +-- .../workflows/payment_method_status_update.rs | 5 ++- crates/scheduler/src/scheduler.rs | 2 +- crates/storage_impl/src/kv_router_store.rs | 40 +++++++++---------- crates/storage_impl/src/lib.rs | 3 +- crates/storage_impl/src/lookup.rs | 3 +- crates/storage_impl/src/payment_method.rs | 17 ++++---- .../src/payments/payment_intent.rs | 3 +- .../src/payouts/payout_attempt.rs | 3 +- crates/storage_impl/src/payouts/payouts.rs | 3 +- crates/storage_impl/src/redis/kv_store.rs | 2 +- crates/storage_impl/src/utils.rs | 1 - 15 files changed, 59 insertions(+), 61 deletions(-) diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rs index 19b03b097a6..3cbc581e0e8 100644 --- a/crates/hyperswitch_domain_models/src/payment_methods.rs +++ b/crates/hyperswitch_domain_models/src/payment_methods.rs @@ -1,25 +1,23 @@ #[cfg(feature = "v2")] use api_models::payment_methods::PaymentMethodsData; +// specific imports because of using the macro +use common_enums::enums::MerchantStorageScheme; +#[cfg(feature = "v2")] +use common_utils::{ + crypto::Encryptable, encryption::Encryption, ext_traits::ValueExt, + types::keymanager::ToEncryptable, +}; #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] use common_utils::{crypto::Encryptable, encryption::Encryption, types::keymanager::ToEncryptable}; use common_utils::{ crypto::OptionalEncryptableValue, errors::{CustomResult, ParsingError, ValidationError}, - pii, type_name, - types::keymanager, + id_type, pii, type_name, + types::{keymanager, keymanager::KeyManagerState}, }; -use diesel_models::enums as storage_enums; +use diesel_models::{enums as storage_enums, PaymentMethodUpdate}; use error_stack::ResultExt; use masking::{PeekInterface, Secret}; -// specific imports because of using the macro -use common_enums::enums::MerchantStorageScheme; -#[cfg(feature = "v2")] -use common_utils::{ - crypto::Encryptable, encryption::Encryption, ext_traits::ValueExt, - types::keymanager::ToEncryptable, -}; -use common_utils::{id_type, types::keymanager::KeyManagerState}; -use diesel_models::PaymentMethodUpdate; #[cfg(feature = "v2")] use rustc_hash::FxHashMap; #[cfg(feature = "v2")] @@ -36,12 +34,12 @@ use crate::{ consts, router_response_types, type_encryption::{crypto_operation, CryptoOperation}, }; -use crate::{errors, merchant_key_store::MerchantKeyStore}; - #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] use crate::{address::Address, type_encryption::OptionalEncryptableJsonType}; use crate::{ + errors, mandates::{CommonMandateReference, PaymentsMandateReference}, + merchant_key_store::MerchantKeyStore, type_encryption::{crypto_operation, AsyncLift, CryptoOperation}, }; diff --git a/crates/payment_methods/src/client.rs b/crates/payment_methods/src/client.rs index 4d558f7aee3..0e63d15b540 100644 --- a/crates/payment_methods/src/client.rs +++ b/crates/payment_methods/src/client.rs @@ -1,5 +1,3 @@ -use storage_impl::{kv_router_store::KVRouterStore, DatabaseStore, MockDb, RouterStore}; - use common_utils::{errors::CustomResult, id_type, types::keymanager::KeyManagerState}; use hyperswitch_domain_models::{ errors, @@ -7,6 +5,7 @@ use hyperswitch_domain_models::{ merchant_key_store::MerchantKeyStore, payment_methods::{PaymentMethod, PaymentMethodInterface}, }; +use storage_impl::{kv_router_store::KVRouterStore, DatabaseStore, MockDb, RouterStore}; #[async_trait::async_trait] pub trait PaymentMethodsStorageInterface: diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs index c349f149eb8..3ee8e3747a6 100644 --- a/crates/router/src/configs/settings.rs +++ b/crates/router/src/configs/settings.rs @@ -25,13 +25,13 @@ use hyperswitch_interfaces::secrets_interface::secret_state::{ RawSecret, SecretState, SecretStateContainer, SecuredSecret, }; use masking::Secret; +use payment_methods::client::PaymentMethodsStorageInterface; use redis_interface::RedisSettings; pub use router_env::config::{Log, LogConsole, LogFile, LogTelemetry}; use rust_decimal::Decimal; use scheduler::SchedulerSettings; use serde::Deserialize; use storage_impl::config::QueueStrategy; -use payment_methods::client::PaymentMethodsStorageInterface; #[cfg(feature = "olap")] use crate::analytics::{AnalyticsConfig, AnalyticsProvider}; @@ -243,7 +243,7 @@ impl TenantConfig { .into_iter() .collect() } - + /// # Panics /// /// Panics if Failed to create event handler diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 0a021c0c4bc..27dbc63c7ee 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -1,6 +1,6 @@ -use ::payment_methods::client::{PaymentMethodsClient, PaymentMethodsStorageInterface}; use std::{collections::HashMap, sync::Arc}; +use ::payment_methods::client::{PaymentMethodsClient, PaymentMethodsStorageInterface}; use actix_web::{web, Scope}; #[cfg(all(feature = "olap", feature = "v1"))] use api_models::routing::RoutingRetrieveQuery; @@ -8,8 +8,7 @@ use api_models::routing::RoutingRetrieveQuery; use common_enums::TransactionType; #[cfg(feature = "partial-auth")] use common_utils::crypto::Blake3; -use common_utils::id_type; -use common_utils::types::keymanager::KeyManagerState; +use common_utils::{id_type, types::keymanager::KeyManagerState}; #[cfg(feature = "email")] use external_services::email::{ no_email::NoEmailClient, ses::AwsSes, smtp::SmtpServer, EmailClientConfigs, EmailService, diff --git a/crates/router/src/workflows/payment_method_status_update.rs b/crates/router/src/workflows/payment_method_status_update.rs index 683d21d4839..73f2053dc52 100644 --- a/crates/router/src/workflows/payment_method_status_update.rs +++ b/crates/router/src/workflows/payment_method_status_update.rs @@ -1,4 +1,5 @@ use common_utils::ext_traits::ValueExt; +use error_stack::ResultExt; use scheduler::{ consumer::types::process_data, utils as pt_utils, workflows::ProcessTrackerWorkflow, }; @@ -9,7 +10,6 @@ use crate::{ routes::SessionState, types::storage::{self, PaymentMethodStatusTrackingData}, }; -use error_stack::ResultExt; pub struct PaymentMethodStatusUpdateWorkflow; #[async_trait::async_trait] @@ -55,7 +55,8 @@ impl ProcessTrackerWorkflow for PaymentMethodStatusUpdateWorkflow &pm_id, merchant_account.storage_scheme, ) - .await.change_context(errors::ApiErrorResponse::InternalServerError) + .await + .change_context(errors::ApiErrorResponse::InternalServerError) .attach_printable("Unable to decode billing address")?; if payment_method.status != prev_pm_status { diff --git a/crates/scheduler/src/scheduler.rs b/crates/scheduler/src/scheduler.rs index 5bdbf33bd28..7a5681147a7 100644 --- a/crates/scheduler/src/scheduler.rs +++ b/crates/scheduler/src/scheduler.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use common_utils::{errors::CustomResult, id_type}; -use storage_impl::mock_db::MockDb; #[cfg(feature = "kv_store")] use storage_impl::kv_router_store::KVRouterStore; +use storage_impl::mock_db::MockDb; #[cfg(not(feature = "kv_store"))] use storage_impl::RouterStore; use tokio::sync::mpsc; diff --git a/crates/storage_impl/src/kv_router_store.rs b/crates/storage_impl/src/kv_router_store.rs index 310f4aed1c5..3d74b3c08d4 100644 --- a/crates/storage_impl/src/kv_router_store.rs +++ b/crates/storage_impl/src/kv_router_store.rs @@ -1,36 +1,34 @@ -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; -use crate::config::TenantConfig; -use crate::errors::RedisErrorExt; -use crate::redis::kv_store::decide_storage_scheme; -use crate::redis::kv_store::kv_wrapper; -use crate::redis::kv_store::KvOperation; -use crate::redis::kv_store::Op; -use crate::redis::kv_store::{KvStorePartition, PartitionKey, RedisConnInterface}; -use crate::utils::find_all_combined_kv_database; -use crate::utils::try_redis_get_else_try_database_get; use common_enums::enums::MerchantStorageScheme; use common_utils::fallback_reverse_lookup_not_found; use diesel_models::{errors::DatabaseError, kv}; use error_stack::ResultExt; use hyperswitch_domain_models::errors::{self, StorageResult}; -use masking::StrongSecret; -use serde::de; -use std::fmt::Debug; - -pub use crate::mock_db::MockDb; -use crate::{database::store::PgPool, RouterStore}; -use crate::{ - diesel_error_to_data_error, lookup::ReverseLookupInterface, metrics, UniqueConstraints, -}; #[cfg(not(feature = "payouts"))] use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface}; +use masking::StrongSecret; use redis_interface::{errors::RedisError, types::HsetnxReply, RedisConnectionPool}; +use router_env::logger; +use serde::de; -pub use crate::database::store::DatabaseStore; #[cfg(not(feature = "payouts"))] pub use crate::database::store::Store; -use router_env::logger; +use crate::{ + config::TenantConfig, + database::store::PgPool, + diesel_error_to_data_error, + errors::RedisErrorExt, + lookup::ReverseLookupInterface, + metrics, + redis::kv_store::{ + decide_storage_scheme, kv_wrapper, KvOperation, KvStorePartition, Op, PartitionKey, + RedisConnInterface, + }, + utils::{find_all_combined_kv_database, try_redis_get_else_try_database_get}, + RouterStore, UniqueConstraints, +}; +pub use crate::{database::store::DatabaseStore, mock_db::MockDb}; #[derive(Debug, Clone)] pub struct KVRouterStore { diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs index 76ca444c9d7..443c5cdb3fa 100644 --- a/crates/storage_impl/src/lib.rs +++ b/crates/storage_impl/src/lib.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{fmt::Debug, sync::Arc}; use diesel_models as store; use error_stack::ResultExt; @@ -9,7 +9,6 @@ use hyperswitch_domain_models::{ }; use masking::StrongSecret; use redis::{kv_store::RedisConnInterface, pub_sub::PubSubInterface, RedisStore}; -use std::fmt::Debug; mod address; pub mod callback_mapper; pub mod config; diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rs index 216c324b886..2ea9cfd5c86 100644 --- a/crates/storage_impl/src/lookup.rs +++ b/crates/storage_impl/src/lookup.rs @@ -12,9 +12,10 @@ use redis_interface::SetnxReply; use crate::{ diesel_error_to_data_error, errors::RedisErrorExt, + kv_router_store::KVRouterStore, redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey}, utils::{self, try_redis_get_else_try_database_get}, - DatabaseStore, kv_router_store::KVRouterStore, RouterStore, + DatabaseStore, RouterStore, }; #[async_trait::async_trait] diff --git a/crates/storage_impl/src/payment_method.rs b/crates/storage_impl/src/payment_method.rs index f067e2b0c2a..f5676fa4326 100644 --- a/crates/storage_impl/src/payment_method.rs +++ b/crates/storage_impl/src/payment_method.rs @@ -11,21 +11,22 @@ use diesel_models::{ payment_method::{PaymentMethodUpdate, PaymentMethodUpdateInternal}, }; use error_stack::ResultExt; -use hyperswitch_domain_models::behaviour::{Conversion, ReverseConversion}; +use hyperswitch_domain_models::{ + behaviour::{Conversion, ReverseConversion}, + errors, + merchant_key_store::MerchantKeyStore, + payment_methods::{PaymentMethod as DomainPaymentMethod, PaymentMethodInterface}, +}; +use router_env::{instrument, tracing}; use super::MockDb; use crate::{ diesel_error_to_data_error, + kv_router_store::{InsertResourceParams, KVRouterStore}, redis::kv_store::{Op, PartitionKey}, utils::{pg_connection_read, pg_connection_write}, + DatabaseStore, RouterStore, }; -use crate::{kv_router_store::{KVRouterStore, InsertResourceParams}, DatabaseStore, RouterStore}; -use hyperswitch_domain_models::{ - errors, - merchant_key_store::MerchantKeyStore, - payment_methods::{PaymentMethod as DomainPaymentMethod, PaymentMethodInterface}, -}; -use router_env::{instrument, tracing}; #[async_trait::async_trait] impl PaymentMethodInterface for KVRouterStore { diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs index dece0b37245..054326fe6a8 100644 --- a/crates/storage_impl/src/payments/payment_intent.rs +++ b/crates/storage_impl/src/payments/payment_intent.rs @@ -51,9 +51,10 @@ use crate::connection; use crate::{ diesel_error_to_data_error, errors::RedisErrorExt, + kv_router_store::KVRouterStore, redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey}, utils::{self, pg_connection_read, pg_connection_write}, - DatabaseStore, kv_router_store::KVRouterStore, + DatabaseStore, }; #[async_trait::async_trait] diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs index 70ba688adc3..a56b3cd2c5a 100644 --- a/crates/storage_impl/src/payouts/payout_attempt.rs +++ b/crates/storage_impl/src/payouts/payout_attempt.rs @@ -29,10 +29,11 @@ use router_env::{instrument, logger, tracing}; use crate::{ diesel_error_to_data_error, errors::RedisErrorExt, + kv_router_store::KVRouterStore, lookup::ReverseLookupInterface, redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey}, utils::{self, pg_connection_read, pg_connection_write}, - DataModelExt, DatabaseStore, kv_router_store::KVRouterStore, + DataModelExt, DatabaseStore, }; #[async_trait::async_trait] diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs index e74299bd60b..25e7dd95f63 100644 --- a/crates/storage_impl/src/payouts/payouts.rs +++ b/crates/storage_impl/src/payouts/payouts.rs @@ -69,9 +69,10 @@ use crate::store::schema::{ use crate::{ diesel_error_to_data_error, errors::RedisErrorExt, + kv_router_store::KVRouterStore, redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey}, utils::{self, pg_connection_read, pg_connection_write}, - DataModelExt, DatabaseStore, kv_router_store::KVRouterStore, + DataModelExt, DatabaseStore, }; #[async_trait::async_trait] diff --git a/crates/storage_impl/src/redis/kv_store.rs b/crates/storage_impl/src/redis/kv_store.rs index cb8721b7458..724a4b1b3c2 100644 --- a/crates/storage_impl/src/redis/kv_store.rs +++ b/crates/storage_impl/src/redis/kv_store.rs @@ -8,7 +8,7 @@ use router_derive::TryGetEnumVariant; use router_env::logger; use serde::de; -use crate::{metrics, store::kv::TypedSql, kv_router_store::KVRouterStore, UniqueConstraints}; +use crate::{kv_router_store::KVRouterStore, metrics, store::kv::TypedSql, UniqueConstraints}; pub trait KvStorePartition { fn partition_number(key: PartitionKey<'_>, num_partitions: u8) -> u32 { diff --git a/crates/storage_impl/src/utils.rs b/crates/storage_impl/src/utils.rs index c505e56c884..a5fb19a93dc 100644 --- a/crates/storage_impl/src/utils.rs +++ b/crates/storage_impl/src/utils.rs @@ -137,4 +137,3 @@ where }, } } -