chore: resolve warnings in v2 (#8373)

Co-authored-by: Aishwariyaa Anand <aishwariyaa.anand@Aishwariyaa-Anand-C3PGW02T6Y.local>
This commit is contained in:
Aishwariyaa Anand
2025-06-22 16:58:23 +05:30
committed by GitHub
parent 0851c6ece5
commit d2d4f3d1d8
50 changed files with 218 additions and 320 deletions

View File

@ -10,8 +10,9 @@ use hyperswitch_domain_models::{
use masking::PeekInterface;
use router_env::{instrument, tracing};
#[cfg(feature = "v1")]
use crate::diesel_error_to_data_error;
use crate::{
diesel_error_to_data_error,
errors::StorageError,
kv_router_store,
redis::kv_store::{decide_storage_scheme, KvStorePartition, Op, PartitionKey},
@ -368,7 +369,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
&self,
state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
_merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@ -402,7 +402,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for kv_router_store::KVRouterSt
state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
customer: domain::Customer,
_merchant_id: &id_type::MerchantId,
customer_update: domain::CustomerUpdate,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
@ -670,11 +669,10 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
&self,
state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
customer: domain::Customer,
merchant_id: &id_type::MerchantId,
_customer: domain::Customer,
customer_update: domain::CustomerUpdate,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
let conn = pg_connection_write(self).await?;
self.call_database(
@ -691,7 +689,6 @@ impl<T: DatabaseStore> domain::CustomerInterface for RouterStore<T> {
&self,
state: &KeyManagerState,
id: &id_type::GlobalCustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
@ -748,10 +745,10 @@ impl domain::CustomerInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_state: &KeyManagerState,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
todo!()
@ -874,7 +871,6 @@ impl domain::CustomerInterface for MockDb {
_state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_customer: domain::Customer,
_merchant_id: &id_type::MerchantId,
_customer_update: domain::CustomerUpdate,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
@ -888,7 +884,6 @@ impl domain::CustomerInterface for MockDb {
&self,
_state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {

View File

@ -32,8 +32,6 @@ pub mod utils;
use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
use database::store::PgPool;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use diesel_models::tokenization::Tokenization;
pub mod tokenization;
#[cfg(not(feature = "payouts"))]
use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};

View File

@ -1,8 +1,10 @@
use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
use diesel_models::enums as storage_enums;
#[cfg(feature = "v1")]
use error_stack::ResultExt;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::behaviour::Conversion;
use hyperswitch_domain_models::{
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payments::{
payment_intent::{PaymentIntentInterface, PaymentIntentUpdate},
@ -32,11 +34,11 @@ impl PaymentIntentInterface for MockDb {
#[cfg(all(feature = "v2", feature = "olap"))]
async fn get_filtered_payment_intents_attempt(
&self,
state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
merchant_key_store: &MerchantKeyStore,
storage_scheme: storage_enums::MerchantStorageScheme,
_state: &KeyManagerState,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints,
_merchant_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<
Vec<(
PaymentIntent,
@ -166,10 +168,10 @@ impl PaymentIntentInterface for MockDb {
#[allow(clippy::unwrap_used)]
async fn update_payment_intent(
&self,
state: &KeyManagerState,
this: PaymentIntent,
update: PaymentIntentUpdate,
key_store: &MerchantKeyStore,
_state: &KeyManagerState,
_this: PaymentIntent,
_update: PaymentIntentUpdate,
_key_store: &MerchantKeyStore,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PaymentIntent, StorageError> {
todo!()

View File

@ -6,13 +6,14 @@ impl KvStorePartition for PaymentMethod {}
use common_enums::enums::MerchantStorageScheme;
use common_utils::{errors::CustomResult, id_type, types::keymanager::KeyManagerState};
use diesel_models::{
kv,
payment_method::{PaymentMethodUpdate, PaymentMethodUpdateInternal},
};
#[cfg(feature = "v1")]
use diesel_models::kv;
use diesel_models::payment_method::{PaymentMethodUpdate, PaymentMethodUpdateInternal};
use error_stack::ResultExt;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::behaviour::ReverseConversion;
use hyperswitch_domain_models::{
behaviour::{Conversion, ReverseConversion},
behaviour::Conversion,
merchant_key_store::MerchantKeyStore,
payment_methods::{PaymentMethod as DomainPaymentMethod, PaymentMethodInterface},
};
@ -21,14 +22,15 @@ use router_env::{instrument, tracing};
use super::MockDb;
use crate::{
diesel_error_to_data_error, errors,
kv_router_store::{
FilterResourceParams, FindResourceBy, InsertResourceParams, KVRouterStore,
UpdateResourceParams,
},
redis::kv_store::{Op, PartitionKey},
kv_router_store::{FindResourceBy, KVRouterStore},
utils::{pg_connection_read, pg_connection_write},
DatabaseStore, RouterStore,
};
#[cfg(feature = "v1")]
use crate::{
kv_router_store::{FilterResourceParams, InsertResourceParams, UpdateResourceParams},
redis::kv_store::{Op, PartitionKey},
};
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
@ -389,7 +391,6 @@ impl<T: DatabaseStore> PaymentMethodInterface for KVRouterStore<T> {
key_store: &MerchantKeyStore,
fingerprint_id: &str,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let conn = pg_connection_read(self).await?;
self.router_store
.find_payment_method_by_fingerprint_id(state, key_store, fingerprint_id)
.await
@ -538,7 +539,7 @@ impl<T: DatabaseStore> PaymentMethodInterface for RouterStore<T> {
key_store: &MerchantKeyStore,
payment_method: DomainPaymentMethod,
payment_method_update: PaymentMethodUpdate,
storage_scheme: MerchantStorageScheme,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<DomainPaymentMethod, errors::StorageError> {
let payment_method = Conversion::convert(payment_method)
.await
@ -837,8 +838,8 @@ impl PaymentMethodInterface for MockDb {
#[cfg(feature = "v2")]
async fn find_payment_method_list_by_global_customer_id(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_id: &id_type::GlobalCustomerId,
_limit: Option<i64>,
) -> CustomResult<Vec<DomainPaymentMethod>, errors::StorageError> {

View File

@ -1,7 +1,8 @@
use common_utils::errors::CustomResult;
#[cfg(feature = "v2")]
use common_utils::types::keymanager::KeyManagerState;
#[cfg(feature = "v1")]
use common_utils::{
errors::CustomResult,
fallback_reverse_lookup_not_found,
types::{ConnectorTransactionId, ConnectorTransactionIdTrait, CreatedBy},
};
@ -10,12 +11,11 @@ use diesel_models::{
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
MandateDetails as DieselMandateDetails, MerchantStorageScheme,
},
kv,
payment_attempt::{
PaymentAttempt as DieselPaymentAttempt, PaymentAttemptNew as DieselPaymentAttemptNew,
},
payment_attempt::PaymentAttempt as DieselPaymentAttempt,
reverse_lookup::{ReverseLookup, ReverseLookupNew},
};
#[cfg(feature = "v1")]
use diesel_models::{kv, payment_attempt::PaymentAttemptNew as DieselPaymentAttemptNew};
use error_stack::ResultExt;
#[cfg(feature = "v1")]
use hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptNew;
@ -28,22 +28,27 @@ use hyperswitch_domain_models::{
mandates::{MandateAmountData, MandateDataType, MandateDetails},
payments::payment_attempt::{PaymentAttempt, PaymentAttemptInterface, PaymentAttemptUpdate},
};
#[cfg(feature = "olap")]
#[cfg(all(feature = "v1", feature = "olap"))]
use hyperswitch_domain_models::{
payments::payment_attempt::PaymentListFilters, payments::PaymentIntent,
};
#[cfg(feature = "v1")]
use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};
use crate::{
diesel_error_to_data_error,
errors::{self, RedisErrorExt},
diesel_error_to_data_error, errors,
kv_router_store::KVRouterStore,
lookup::ReverseLookupInterface,
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
utils::{pg_connection_read, pg_connection_write, try_redis_get_else_try_database_get},
utils::{pg_connection_read, pg_connection_write},
DataModelExt, DatabaseStore, RouterStore,
};
#[cfg(feature = "v1")]
use crate::{
errors::RedisErrorExt,
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
utils::try_redis_get_else_try_database_get,
};
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {

View File

@ -2,14 +2,11 @@
use api_models::payments::{AmountFilter, Order, SortBy, SortOn};
#[cfg(feature = "olap")]
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::{
ext_traits::{AsyncExt, Encode},
types::keymanager::KeyManagerState,
};
#[cfg(feature = "v1")]
use common_utils::ext_traits::Encode;
use common_utils::{ext_traits::AsyncExt, types::keymanager::KeyManagerState};
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
#[cfg(feature = "v1")]
use diesel_models::payment_intent::PaymentIntentUpdate as DieselPaymentIntentUpdate;
#[cfg(feature = "olap")]
use diesel_models::query::generics::db_metrics;
#[cfg(all(feature = "v1", feature = "olap"))]
@ -23,8 +20,10 @@ use diesel_models::schema_v2::{
payment_intent::dsl as pi_dsl,
};
use diesel_models::{
enums::MerchantStorageScheme, kv, payment_intent::PaymentIntent as DieselPaymentIntent,
enums::MerchantStorageScheme, payment_intent::PaymentIntent as DieselPaymentIntent,
};
#[cfg(feature = "v1")]
use diesel_models::{kv, payment_intent::PaymentIntentUpdate as DieselPaymentIntentUpdate};
use error_stack::ResultExt;
#[cfg(feature = "olap")]
use hyperswitch_domain_models::payments::{
@ -38,6 +37,7 @@ use hyperswitch_domain_models::{
PaymentIntent,
},
};
#[cfg(feature = "v1")]
use redis_interface::HsetnxReply;
#[cfg(feature = "olap")]
use router_env::logger;
@ -47,12 +47,17 @@ use router_env::{instrument, tracing};
use crate::connection;
use crate::{
diesel_error_to_data_error,
errors::{RedisErrorExt, StorageError},
errors::StorageError,
kv_router_store::KVRouterStore,
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
utils::{self, pg_connection_read, pg_connection_write},
utils::{pg_connection_read, pg_connection_write},
DatabaseStore,
};
#[cfg(feature = "v1")]
use crate::{
errors::RedisErrorExt,
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
utils,
};
#[async_trait::async_trait]
impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
@ -1136,8 +1141,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
use diesel::NullableExpressionMethods as _;
use futures::{future::try_join_all, FutureExt};
use crate::DataModelExt;
let conn = connection::pg_connection_read(self).await?;
let conn = async_bb8_diesel::Connection::as_async_conn(&conn);
let mut query = DieselPaymentIntent::table()

View File

@ -4,18 +4,13 @@ use api_models::enums::PayoutConnectors;
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::ext_traits::Encode;
#[cfg(feature = "olap")]
use diesel::{
associations::HasTable, ExpressionMethods, JoinOnDsl, NullableExpressionMethods, QueryDsl,
};
#[cfg(all(feature = "olap", feature = "v1"))]
use diesel_models::schema::{
address::dsl as add_dsl, customers::dsl as cust_dsl, payout_attempt::dsl as poa_dsl,
};
use diesel::{associations::HasTable, ExpressionMethods, QueryDsl};
#[cfg(all(feature = "v1", feature = "olap"))]
use diesel::{JoinOnDsl, NullableExpressionMethods};
#[cfg(feature = "olap")]
use diesel_models::{
address::Address as DieselAddress, customers::Customer as DieselCustomer,
enums as storage_enums, payout_attempt::PayoutAttempt as DieselPayoutAttempt,
query::generics::db_metrics, schema::payouts::dsl as po_dsl,
enums as storage_enums, query::generics::db_metrics, schema::payouts::dsl as po_dsl,
};
use diesel_models::{
enums::MerchantStorageScheme,
@ -25,6 +20,11 @@ use diesel_models::{
PayoutsUpdate as DieselPayoutsUpdate,
},
};
#[cfg(all(feature = "olap", feature = "v1"))]
use diesel_models::{
payout_attempt::PayoutAttempt as DieselPayoutAttempt,
schema::{address::dsl as add_dsl, customers::dsl as cust_dsl, payout_attempt::dsl as poa_dsl},
};
use error_stack::ResultExt;
#[cfg(feature = "olap")]
use hyperswitch_domain_models::payouts::PayoutFetchConstraints;
@ -876,8 +876,8 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {
#[instrument(skip_all)]
async fn filter_active_payout_ids_by_constraints(
&self,
merchant_id: &common_utils::id_type::MerchantId,
constraints: &PayoutFetchConstraints,
_merchant_id: &common_utils::id_type::MerchantId,
_constraints: &PayoutFetchConstraints,
) -> error_stack::Result<Vec<String>, StorageError> {
todo!()
}

View File

@ -1,41 +1,16 @@
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use async_bb8_diesel::AsyncRunQueryDsl;
use common_utils::{errors::CustomResult, types::keymanager::KeyManagerState};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use common_utils::{
errors::CustomResult,
ext_traits::OptionExt,
id_type::{CellId, GlobalTokenId, MerchantId},
types::keymanager::KeyManagerState,
};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use diesel::{ExpressionMethods, Insertable, RunQueryDsl};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use diesel_models::{
enums::TokenizationFlag as DbTokenizationFlag,
schema_v2::tokenization::dsl as tokenization_dsl, tokenization, PgPooledConn,
};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use error_stack::{report, Report, ResultExt};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use hyperswitch_domain_models::tokenization::Tokenization;
use error_stack::{report, ResultExt};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use hyperswitch_domain_models::{
behaviour::{Conversion, ReverseConversion},
merchant_key_store::MerchantKeyStore,
};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use tokio::time;
use super::MockDb;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use crate::{
connection, diesel_error_to_data_error, errors,
kv_router_store::{
FilterResourceParams, FindResourceBy, InsertResourceParams, UpdateResourceParams,
},
redis::kv_store::{Op, PartitionKey},
utils::{pg_connection_read, pg_connection_write},
};
use crate::{connection, errors};
use crate::{kv_router_store::KVRouterStore, DatabaseStore, RouterStore};
#[cfg(not(all(feature = "v2", feature = "tokenization_v2")))]
@ -146,18 +121,18 @@ impl<T: DatabaseStore> TokenizationInterface for KVRouterStore<T> {
impl TokenizationInterface for MockDb {
async fn insert_tokenization(
&self,
tokenization: hyperswitch_domain_models::tokenization::Tokenization,
merchant_key_store: &MerchantKeyStore,
key_manager_state: &KeyManagerState,
_tokenization: hyperswitch_domain_models::tokenization::Tokenization,
_merchant_key_store: &MerchantKeyStore,
_key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
Err(errors::StorageError::MockDbError)?
}
async fn get_entity_id_vault_id_by_token_id(
&self,
token: &common_utils::id_type::GlobalTokenId,
merchant_key_store: &MerchantKeyStore,
key_manager_state: &KeyManagerState,
_token: &common_utils::id_type::GlobalTokenId,
_merchant_key_store: &MerchantKeyStore,
_key_manager_state: &KeyManagerState,
) -> CustomResult<hyperswitch_domain_models::tokenization::Tokenization, errors::StorageError>
{
Err(errors::StorageError::MockDbError)?