feat(payouts): add kafka events (#4264)

Co-authored-by: Ivor Dsouza <ivor.dsouza@juspay.in>
Co-authored-by: ivor-juspay <138492857+ivor-juspay@users.noreply.github.com>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Kashif
2024-04-10 14:43:20 +05:30
committed by GitHub
parent 13ba3cbd96
commit a2958c33b5
16 changed files with 241 additions and 102 deletions

View File

@ -1,8 +1,11 @@
use common_utils::errors::CustomResult;
use data_models::{
errors::StorageError,
payouts::payout_attempt::{
PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
payouts::{
payout_attempt::{
PayoutAttempt, PayoutAttemptInterface, PayoutAttemptNew, PayoutAttemptUpdate,
},
payouts::Payouts,
},
};
use diesel_models::enums as storage_enums;
@ -15,6 +18,7 @@ impl PayoutAttemptInterface for MockDb {
&self,
_this: &PayoutAttempt,
_payout_attempt_update: PayoutAttemptUpdate,
_payouts: &Payouts,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PayoutAttempt, StorageError> {
// TODO: Implement function for `MockDb`
@ -23,7 +27,8 @@ impl PayoutAttemptInterface for MockDb {
async fn insert_payout_attempt(
&self,
_payout: PayoutAttemptNew,
_payout_attempt: PayoutAttemptNew,
_payouts: &Payouts,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<PayoutAttempt, StorageError> {
// TODO: Implement function for `MockDb`
@ -42,7 +47,7 @@ impl PayoutAttemptInterface for MockDb {
async fn get_filters_for_payouts(
&self,
_payouts: &[data_models::payouts::payouts::Payouts],
_payouts: &[Payouts],
_merchant_id: &str,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<data_models::payouts::payout_attempt::PayoutListFilters, StorageError> {

View File

@ -1,9 +1,10 @@
use common_utils::errors::CustomResult;
#[cfg(all(feature = "olap", feature = "payouts"))]
use data_models::payouts::payout_attempt::PayoutAttempt;
use data_models::{
errors::StorageError,
payouts::payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
payouts::{
payout_attempt::PayoutAttempt,
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
},
};
use diesel_models::enums as storage_enums;
@ -25,6 +26,7 @@ impl PayoutsInterface for MockDb {
&self,
_this: &Payouts,
_payout_update: PayoutsUpdate,
_payout_attempt: &PayoutAttempt,
_storage_scheme: storage_enums::MerchantStorageScheme,
) -> CustomResult<Payouts, StorageError> {
// TODO: Implement function for `MockDb`

View File

@ -40,12 +40,13 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
async fn insert_payout_attempt(
&self,
new_payout_attempt: PayoutAttemptNew,
payouts: &Payouts,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.insert_payout_attempt(new_payout_attempt, storage_scheme)
.insert_payout_attempt(new_payout_attempt, payouts, storage_scheme)
.await
}
MerchantStorageScheme::RedisKv => {
@ -129,12 +130,13 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
&self,
this: &PayoutAttempt,
payout_update: PayoutAttemptUpdate,
payouts: &Payouts,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.update_payout_attempt(this, payout_update, storage_scheme)
.update_payout_attempt(this, payout_update, payouts, storage_scheme)
.await
}
MerchantStorageScheme::RedisKv => {
@ -254,6 +256,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for crate::RouterStore<T> {
async fn insert_payout_attempt(
&self,
new: PayoutAttemptNew,
_payouts: &Payouts,
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;
@ -272,6 +275,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for crate::RouterStore<T> {
&self,
this: &PayoutAttempt,
payout: PayoutAttemptUpdate,
_payouts: &Payouts,
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
let conn = pg_connection_write(self).await?;

View File

@ -2,10 +2,13 @@
use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::ext_traits::Encode;
#[cfg(feature = "olap")]
use data_models::payouts::{payout_attempt::PayoutAttempt, PayoutFetchConstraints};
use data_models::payouts::PayoutFetchConstraints;
use data_models::{
errors::StorageError,
payouts::payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
payouts::{
payout_attempt::PayoutAttempt,
payouts::{Payouts, PayoutsInterface, PayoutsNew, PayoutsUpdate},
},
};
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
@ -115,12 +118,13 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
&self,
this: &Payouts,
payout_update: PayoutsUpdate,
payout_attempt: &PayoutAttempt,
storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Payouts, StorageError> {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
self.router_store
.update_payout(this, payout_update, storage_scheme)
.update_payout(this, payout_update, payout_attempt, storage_scheme)
.await
}
MerchantStorageScheme::RedisKv => {
@ -316,6 +320,7 @@ impl<T: DatabaseStore> PayoutsInterface for crate::RouterStore<T> {
&self,
this: &Payouts,
payout: PayoutsUpdate,
_payout_attempt: &PayoutAttempt,
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<Payouts, StorageError> {
let conn = pg_connection_write(self).await?;