mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
feat: Soft kill kv (#4582)
Co-authored-by: Akshay S <akshay.s@Akshay-Subramanian-D66TQ6D97K.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -38,7 +38,7 @@ use crate::connection;
|
||||
use crate::{
|
||||
diesel_error_to_data_error,
|
||||
errors::RedisErrorExt,
|
||||
redis::kv_store::{kv_wrapper, KvOperation, PartitionKey},
|
||||
redis::kv_store::{decide_storage_scheme, kv_wrapper, KvOperation, Op, PartitionKey},
|
||||
utils::{self, pg_connection_read, pg_connection_write},
|
||||
DataModelExt, DatabaseStore, KVRouterStore,
|
||||
};
|
||||
@ -51,6 +51,8 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
new: PayoutsNew,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Payouts, StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Insert).await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store.insert_payout(new, storage_scheme).await
|
||||
@ -128,6 +130,17 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
payout_attempt: &PayoutAttempt,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Payouts, StorageError> {
|
||||
let key = PartitionKey::MerchantIdPayoutId {
|
||||
merchant_id: &this.merchant_id,
|
||||
payout_id: &this.payout_id,
|
||||
};
|
||||
let field = format!("po_{}", this.payout_id);
|
||||
let storage_scheme = decide_storage_scheme::<_, DieselPayouts>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Update(key.clone(), &field, None),
|
||||
)
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -135,12 +148,7 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
.await
|
||||
}
|
||||
MerchantStorageScheme::RedisKv => {
|
||||
let key = PartitionKey::MerchantIdPayoutId {
|
||||
merchant_id: &this.merchant_id,
|
||||
payout_id: &this.payout_id,
|
||||
};
|
||||
let key_str = key.to_string();
|
||||
let field = format!("po_{}", this.payout_id);
|
||||
|
||||
let diesel_payout_update = payout_update.to_storage_model();
|
||||
let origin_diesel_payout = this.clone().to_storage_model();
|
||||
@ -194,6 +202,8 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Find).await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
MerchantStorageScheme::RedisKv => {
|
||||
@ -236,6 +246,8 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Find).await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
let maybe_payouts = database_call().await?;
|
||||
|
||||
Reference in New Issue
Block a user