mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	refactor(db): Add TenantID field to KafkaEvent struct (#4598)
Co-authored-by: Sampras Lopes <sampras.lopes@juspay.in>
This commit is contained in:
		| @ -76,7 +76,7 @@ use crate::{ | |||||||
|     }, |     }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #[derive(Clone, Serialize)] | #[derive(Debug, Clone, Serialize)] | ||||||
| pub struct TenantID(pub String); | pub struct TenantID(pub String); | ||||||
|  |  | ||||||
| #[derive(Clone)] | #[derive(Clone)] | ||||||
| @ -413,7 +413,11 @@ impl DisputeInterface for KafkaStore { | |||||||
|     ) -> CustomResult<storage::Dispute, errors::StorageError> { |     ) -> CustomResult<storage::Dispute, errors::StorageError> { | ||||||
|         let dispute = self.diesel_store.insert_dispute(dispute_new).await?; |         let dispute = self.diesel_store.insert_dispute(dispute_new).await?; | ||||||
|  |  | ||||||
|         if let Err(er) = self.kafka_producer.log_dispute(&dispute, None).await { |         if let Err(er) = self | ||||||
|  |             .kafka_producer | ||||||
|  |             .log_dispute(&dispute, None, self.tenant_id.clone()) | ||||||
|  |             .await | ||||||
|  |         { | ||||||
|             logger::error!(message="Failed to add analytics entry for Dispute {dispute:?}", error_message=?er); |             logger::error!(message="Failed to add analytics entry for Dispute {dispute:?}", error_message=?er); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
| @ -466,7 +470,7 @@ impl DisputeInterface for KafkaStore { | |||||||
|             .await?; |             .await?; | ||||||
|         if let Err(er) = self |         if let Err(er) = self | ||||||
|             .kafka_producer |             .kafka_producer | ||||||
|             .log_dispute(&dispute_new, Some(this)) |             .log_dispute(&dispute_new, Some(this), self.tenant_id.clone()) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
|             logger::error!(message="Failed to add analytics entry for Dispute {dispute_new:?}", error_message=?er); |             logger::error!(message="Failed to add analytics entry for Dispute {dispute_new:?}", error_message=?er); | ||||||
| @ -1109,7 +1113,7 @@ impl PaymentAttemptInterface for KafkaStore { | |||||||
|  |  | ||||||
|         if let Err(er) = self |         if let Err(er) = self | ||||||
|             .kafka_producer |             .kafka_producer | ||||||
|             .log_payment_attempt(&attempt, None) |             .log_payment_attempt(&attempt, None, self.tenant_id.clone()) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
|             logger::error!(message="Failed to log analytics event for payment attempt {attempt:?}", error_message=?er) |             logger::error!(message="Failed to log analytics event for payment attempt {attempt:?}", error_message=?er) | ||||||
| @ -1131,7 +1135,7 @@ impl PaymentAttemptInterface for KafkaStore { | |||||||
|  |  | ||||||
|         if let Err(er) = self |         if let Err(er) = self | ||||||
|             .kafka_producer |             .kafka_producer | ||||||
|             .log_payment_attempt(&attempt, Some(this)) |             .log_payment_attempt(&attempt, Some(this), self.tenant_id.clone()) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
|             logger::error!(message="Failed to log analytics event for payment attempt {attempt:?}", error_message=?er) |             logger::error!(message="Failed to log analytics event for payment attempt {attempt:?}", error_message=?er) | ||||||
| @ -1311,7 +1315,7 @@ impl PaymentIntentInterface for KafkaStore { | |||||||
|  |  | ||||||
|         if let Err(er) = self |         if let Err(er) = self | ||||||
|             .kafka_producer |             .kafka_producer | ||||||
|             .log_payment_intent(&intent, Some(this)) |             .log_payment_intent(&intent, Some(this), self.tenant_id.clone()) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
|             logger::error!(message="Failed to add analytics entry for Payment Intent {intent:?}", error_message=?er); |             logger::error!(message="Failed to add analytics entry for Payment Intent {intent:?}", error_message=?er); | ||||||
| @ -1331,7 +1335,11 @@ impl PaymentIntentInterface for KafkaStore { | |||||||
|             .insert_payment_intent(new, storage_scheme) |             .insert_payment_intent(new, storage_scheme) | ||||||
|             .await?; |             .await?; | ||||||
|  |  | ||||||
|         if let Err(er) = self.kafka_producer.log_payment_intent(&intent, None).await { |         if let Err(er) = self | ||||||
|  |             .kafka_producer | ||||||
|  |             .log_payment_intent(&intent, None, self.tenant_id.clone()) | ||||||
|  |             .await | ||||||
|  |         { | ||||||
|             logger::error!(message="Failed to add analytics entry for Payment Intent {intent:?}", error_message=?er); |             logger::error!(message="Failed to add analytics entry for Payment Intent {intent:?}", error_message=?er); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
| @ -1558,6 +1566,7 @@ impl PayoutAttemptInterface for KafkaStore { | |||||||
|             .log_payout( |             .log_payout( | ||||||
|                 &KafkaPayout::from_storage(payouts, &updated_payout_attempt), |                 &KafkaPayout::from_storage(payouts, &updated_payout_attempt), | ||||||
|                 Some(KafkaPayout::from_storage(payouts, this)), |                 Some(KafkaPayout::from_storage(payouts, this)), | ||||||
|  |                 self.tenant_id.clone(), | ||||||
|             ) |             ) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
| @ -1582,6 +1591,7 @@ impl PayoutAttemptInterface for KafkaStore { | |||||||
|             .log_payout( |             .log_payout( | ||||||
|                 &KafkaPayout::from_storage(payouts, &payout_attempt_new), |                 &KafkaPayout::from_storage(payouts, &payout_attempt_new), | ||||||
|                 None, |                 None, | ||||||
|  |                 self.tenant_id.clone(), | ||||||
|             ) |             ) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
| @ -1639,6 +1649,7 @@ impl PayoutsInterface for KafkaStore { | |||||||
|             .log_payout( |             .log_payout( | ||||||
|                 &KafkaPayout::from_storage(&payout, payout_attempt), |                 &KafkaPayout::from_storage(&payout, payout_attempt), | ||||||
|                 Some(KafkaPayout::from_storage(this, payout_attempt)), |                 Some(KafkaPayout::from_storage(this, payout_attempt)), | ||||||
|  |                 self.tenant_id.clone(), | ||||||
|             ) |             ) | ||||||
|             .await |             .await | ||||||
|         { |         { | ||||||
| @ -1903,7 +1914,11 @@ impl RefundInterface for KafkaStore { | |||||||
|             .update_refund(this.clone(), refund, storage_scheme) |             .update_refund(this.clone(), refund, storage_scheme) | ||||||
|             .await?; |             .await?; | ||||||
|  |  | ||||||
|         if let Err(er) = self.kafka_producer.log_refund(&refund, Some(this)).await { |         if let Err(er) = self | ||||||
|  |             .kafka_producer | ||||||
|  |             .log_refund(&refund, Some(this), self.tenant_id.clone()) | ||||||
|  |             .await | ||||||
|  |         { | ||||||
|             logger::error!(message="Failed to insert analytics event for Refund Update {refund?}", error_message=?er); |             logger::error!(message="Failed to insert analytics event for Refund Update {refund?}", error_message=?er); | ||||||
|         } |         } | ||||||
|         Ok(refund) |         Ok(refund) | ||||||
| @ -1931,7 +1946,11 @@ impl RefundInterface for KafkaStore { | |||||||
|     ) -> CustomResult<storage::Refund, errors::StorageError> { |     ) -> CustomResult<storage::Refund, errors::StorageError> { | ||||||
|         let refund = self.diesel_store.insert_refund(new, storage_scheme).await?; |         let refund = self.diesel_store.insert_refund(new, storage_scheme).await?; | ||||||
|  |  | ||||||
|         if let Err(er) = self.kafka_producer.log_refund(&refund, None).await { |         if let Err(er) = self | ||||||
|  |             .kafka_producer | ||||||
|  |             .log_refund(&refund, None, self.tenant_id.clone()) | ||||||
|  |             .await | ||||||
|  |         { | ||||||
|             logger::error!(message="Failed to insert analytics event for Refund Create {refund?}", error_message=?er); |             logger::error!(message="Failed to insert analytics event for Refund Create {refund?}", error_message=?er); | ||||||
|         } |         } | ||||||
|         Ok(refund) |         Ok(refund) | ||||||
| @ -2504,7 +2523,7 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|         for payment_intent in payment_intents_list.iter() { |         for payment_intent in payment_intents_list.iter() { | ||||||
|             let _ = self |             let _ = self | ||||||
|                 .kafka_producer |                 .kafka_producer | ||||||
|                 .log_payment_intent(payment_intent, None) |                 .log_payment_intent(payment_intent, None, self.tenant_id.clone()) | ||||||
|                 .await; |                 .await; | ||||||
|         } |         } | ||||||
|         Ok(payment_intents_list) |         Ok(payment_intents_list) | ||||||
| @ -2525,7 +2544,7 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|         for payment_attempt in payment_attempts_list.iter() { |         for payment_attempt in payment_attempts_list.iter() { | ||||||
|             let _ = self |             let _ = self | ||||||
|                 .kafka_producer |                 .kafka_producer | ||||||
|                 .log_payment_attempt(payment_attempt, None) |                 .log_payment_attempt(payment_attempt, None, self.tenant_id.clone()) | ||||||
|                 .await; |                 .await; | ||||||
|         } |         } | ||||||
|         Ok(payment_attempts_list) |         Ok(payment_attempts_list) | ||||||
| @ -2542,7 +2561,10 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|             .await?; |             .await?; | ||||||
|  |  | ||||||
|         for refund in refunds_list.iter() { |         for refund in refunds_list.iter() { | ||||||
|             let _ = self.kafka_producer.log_refund(refund, None).await; |             let _ = self | ||||||
|  |                 .kafka_producer | ||||||
|  |                 .log_refund(refund, None, self.tenant_id.clone()) | ||||||
|  |                 .await; | ||||||
|         } |         } | ||||||
|         Ok(refunds_list) |         Ok(refunds_list) | ||||||
|     } |     } | ||||||
| @ -2562,7 +2584,7 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|         for payment_intent in payment_intents_list.iter() { |         for payment_intent in payment_intents_list.iter() { | ||||||
|             let _ = self |             let _ = self | ||||||
|                 .kafka_producer |                 .kafka_producer | ||||||
|                 .log_payment_intent_delete(payment_intent) |                 .log_payment_intent_delete(payment_intent, self.tenant_id.clone()) | ||||||
|                 .await; |                 .await; | ||||||
|         } |         } | ||||||
|         Ok(payment_intents_list) |         Ok(payment_intents_list) | ||||||
| @ -2583,7 +2605,7 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|         for payment_attempt in payment_attempts_list.iter() { |         for payment_attempt in payment_attempts_list.iter() { | ||||||
|             let _ = self |             let _ = self | ||||||
|                 .kafka_producer |                 .kafka_producer | ||||||
|                 .log_payment_attempt_delete(payment_attempt) |                 .log_payment_attempt_delete(payment_attempt, self.tenant_id.clone()) | ||||||
|                 .await; |                 .await; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @ -2601,7 +2623,10 @@ impl BatchSampleDataInterface for KafkaStore { | |||||||
|             .await?; |             .await?; | ||||||
|  |  | ||||||
|         for refund in refunds_list.iter() { |         for refund in refunds_list.iter() { | ||||||
|             let _ = self.kafka_producer.log_refund_delete(refund).await; |             let _ = self | ||||||
|  |                 .kafka_producer | ||||||
|  |                 .log_refund_delete(refund, self.tenant_id.clone()) | ||||||
|  |                 .await; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Ok(refunds_list) |         Ok(refunds_list) | ||||||
|  | |||||||
| @ -30,6 +30,7 @@ use crate::types::storage::Dispute; | |||||||
|  |  | ||||||
| // Using message queue result here to avoid confusion with Kafka result provided by library | // Using message queue result here to avoid confusion with Kafka result provided by library | ||||||
| pub type MQResult<T> = CustomResult<T, KafkaError>; | pub type MQResult<T> = CustomResult<T, KafkaError>; | ||||||
|  | use crate::db::kafka_store::TenantID; | ||||||
|  |  | ||||||
| pub trait KafkaMessage | pub trait KafkaMessage | ||||||
| where | where | ||||||
| @ -54,19 +55,22 @@ struct KafkaEvent<'a, T: KafkaMessage> { | |||||||
|     #[serde(flatten)] |     #[serde(flatten)] | ||||||
|     event: &'a T, |     event: &'a T, | ||||||
|     sign_flag: i32, |     sign_flag: i32, | ||||||
|  |     tenant_id: TenantID, | ||||||
| } | } | ||||||
|  |  | ||||||
| impl<'a, T: KafkaMessage> KafkaEvent<'a, T> { | impl<'a, T: KafkaMessage> KafkaEvent<'a, T> { | ||||||
|     fn new(event: &'a T) -> Self { |     fn new(event: &'a T, tenant_id: TenantID) -> Self { | ||||||
|         Self { |         Self { | ||||||
|             event, |             event, | ||||||
|             sign_flag: 1, |             sign_flag: 1, | ||||||
|  |             tenant_id, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     fn old(event: &'a T) -> Self { |     fn old(event: &'a T, tenant_id: TenantID) -> Self { | ||||||
|         Self { |         Self { | ||||||
|             event, |             event, | ||||||
|             sign_flag: -1, |             sign_flag: -1, | ||||||
|  |             tenant_id, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -266,28 +270,33 @@ impl KafkaProducer { | |||||||
|         &self, |         &self, | ||||||
|         attempt: &PaymentAttempt, |         attempt: &PaymentAttempt, | ||||||
|         old_attempt: Option<PaymentAttempt>, |         old_attempt: Option<PaymentAttempt>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         if let Some(negative_event) = old_attempt { |         if let Some(negative_event) = old_attempt { | ||||||
|             self.log_event(&KafkaEvent::old(&KafkaPaymentAttempt::from_storage( |             self.log_event(&KafkaEvent::old( | ||||||
|                 &negative_event, |                 &KafkaPaymentAttempt::from_storage(&negative_event), | ||||||
|             ))) |                 tenant_id.clone(), | ||||||
|  |             )) | ||||||
|             .attach_printable_lazy(|| { |             .attach_printable_lazy(|| { | ||||||
|                 format!("Failed to add negative attempt event {negative_event:?}") |                 format!("Failed to add negative attempt event {negative_event:?}") | ||||||
|             })?; |             })?; | ||||||
|         }; |         }; | ||||||
|         self.log_event(&KafkaEvent::new(&KafkaPaymentAttempt::from_storage( |         self.log_event(&KafkaEvent::new( | ||||||
|             attempt, |             &KafkaPaymentAttempt::from_storage(attempt), | ||||||
|         ))) |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| format!("Failed to add positive attempt event {attempt:?}")) |         .attach_printable_lazy(|| format!("Failed to add positive attempt event {attempt:?}")) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     pub async fn log_payment_attempt_delete( |     pub async fn log_payment_attempt_delete( | ||||||
|         &self, |         &self, | ||||||
|         delete_old_attempt: &PaymentAttempt, |         delete_old_attempt: &PaymentAttempt, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         self.log_event(&KafkaEvent::old(&KafkaPaymentAttempt::from_storage( |         self.log_event(&KafkaEvent::old( | ||||||
|             delete_old_attempt, |             &KafkaPaymentAttempt::from_storage(delete_old_attempt), | ||||||
|         ))) |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| { |         .attach_printable_lazy(|| { | ||||||
|             format!("Failed to add negative attempt event {delete_old_attempt:?}") |             format!("Failed to add negative attempt event {delete_old_attempt:?}") | ||||||
|         }) |         }) | ||||||
| @ -297,48 +306,69 @@ impl KafkaProducer { | |||||||
|         &self, |         &self, | ||||||
|         intent: &PaymentIntent, |         intent: &PaymentIntent, | ||||||
|         old_intent: Option<PaymentIntent>, |         old_intent: Option<PaymentIntent>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         if let Some(negative_event) = old_intent { |         if let Some(negative_event) = old_intent { | ||||||
|             self.log_event(&KafkaEvent::old(&KafkaPaymentIntent::from_storage( |             self.log_event(&KafkaEvent::old( | ||||||
|                 &negative_event, |                 &KafkaPaymentIntent::from_storage(&negative_event), | ||||||
|             ))) |                 tenant_id.clone(), | ||||||
|  |             )) | ||||||
|             .attach_printable_lazy(|| { |             .attach_printable_lazy(|| { | ||||||
|                 format!("Failed to add negative intent event {negative_event:?}") |                 format!("Failed to add negative intent event {negative_event:?}") | ||||||
|             })?; |             })?; | ||||||
|         }; |         }; | ||||||
|         self.log_event(&KafkaEvent::new(&KafkaPaymentIntent::from_storage(intent))) |         self.log_event(&KafkaEvent::new( | ||||||
|  |             &KafkaPaymentIntent::from_storage(intent), | ||||||
|  |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| format!("Failed to add positive intent event {intent:?}")) |         .attach_printable_lazy(|| format!("Failed to add positive intent event {intent:?}")) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     pub async fn log_payment_intent_delete( |     pub async fn log_payment_intent_delete( | ||||||
|         &self, |         &self, | ||||||
|         delete_old_intent: &PaymentIntent, |         delete_old_intent: &PaymentIntent, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         self.log_event(&KafkaEvent::old(&KafkaPaymentIntent::from_storage( |         self.log_event(&KafkaEvent::old( | ||||||
|             delete_old_intent, |             &KafkaPaymentIntent::from_storage(delete_old_intent), | ||||||
|         ))) |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| { |         .attach_printable_lazy(|| { | ||||||
|             format!("Failed to add negative intent event {delete_old_intent:?}") |             format!("Failed to add negative intent event {delete_old_intent:?}") | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     pub async fn log_refund(&self, refund: &Refund, old_refund: Option<Refund>) -> MQResult<()> { |     pub async fn log_refund( | ||||||
|  |         &self, | ||||||
|  |         refund: &Refund, | ||||||
|  |         old_refund: Option<Refund>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|  |     ) -> MQResult<()> { | ||||||
|         if let Some(negative_event) = old_refund { |         if let Some(negative_event) = old_refund { | ||||||
|             self.log_event(&KafkaEvent::old(&KafkaRefund::from_storage( |             self.log_event(&KafkaEvent::old( | ||||||
|                 &negative_event, |                 &KafkaRefund::from_storage(&negative_event), | ||||||
|             ))) |                 tenant_id.clone(), | ||||||
|  |             )) | ||||||
|             .attach_printable_lazy(|| { |             .attach_printable_lazy(|| { | ||||||
|                 format!("Failed to add negative refund event {negative_event:?}") |                 format!("Failed to add negative refund event {negative_event:?}") | ||||||
|             })?; |             })?; | ||||||
|         }; |         }; | ||||||
|         self.log_event(&KafkaEvent::new(&KafkaRefund::from_storage(refund))) |         self.log_event(&KafkaEvent::new( | ||||||
|  |             &KafkaRefund::from_storage(refund), | ||||||
|  |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| format!("Failed to add positive refund event {refund:?}")) |         .attach_printable_lazy(|| format!("Failed to add positive refund event {refund:?}")) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     pub async fn log_refund_delete(&self, delete_old_refund: &Refund) -> MQResult<()> { |     pub async fn log_refund_delete( | ||||||
|         self.log_event(&KafkaEvent::old(&KafkaRefund::from_storage( |         &self, | ||||||
|             delete_old_refund, |         delete_old_refund: &Refund, | ||||||
|         ))) |         tenant_id: TenantID, | ||||||
|  |     ) -> MQResult<()> { | ||||||
|  |         self.log_event(&KafkaEvent::old( | ||||||
|  |             &KafkaRefund::from_storage(delete_old_refund), | ||||||
|  |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| { |         .attach_printable_lazy(|| { | ||||||
|             format!("Failed to add negative refund event {delete_old_refund:?}") |             format!("Failed to add negative refund event {delete_old_refund:?}") | ||||||
|         }) |         }) | ||||||
| @ -348,16 +378,21 @@ impl KafkaProducer { | |||||||
|         &self, |         &self, | ||||||
|         dispute: &Dispute, |         dispute: &Dispute, | ||||||
|         old_dispute: Option<Dispute>, |         old_dispute: Option<Dispute>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         if let Some(negative_event) = old_dispute { |         if let Some(negative_event) = old_dispute { | ||||||
|             self.log_event(&KafkaEvent::old(&KafkaDispute::from_storage( |             self.log_event(&KafkaEvent::old( | ||||||
|                 &negative_event, |                 &KafkaDispute::from_storage(&negative_event), | ||||||
|             ))) |                 tenant_id.clone(), | ||||||
|  |             )) | ||||||
|             .attach_printable_lazy(|| { |             .attach_printable_lazy(|| { | ||||||
|                 format!("Failed to add negative dispute event {negative_event:?}") |                 format!("Failed to add negative dispute event {negative_event:?}") | ||||||
|             })?; |             })?; | ||||||
|         }; |         }; | ||||||
|         self.log_event(&KafkaEvent::new(&KafkaDispute::from_storage(dispute))) |         self.log_event(&KafkaEvent::new( | ||||||
|  |             &KafkaDispute::from_storage(dispute), | ||||||
|  |             tenant_id.clone(), | ||||||
|  |         )) | ||||||
|         .attach_printable_lazy(|| format!("Failed to add positive dispute event {dispute:?}")) |         .attach_printable_lazy(|| format!("Failed to add positive dispute event {dispute:?}")) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -366,20 +401,25 @@ impl KafkaProducer { | |||||||
|         &self, |         &self, | ||||||
|         payout: &KafkaPayout<'_>, |         payout: &KafkaPayout<'_>, | ||||||
|         old_payout: Option<KafkaPayout<'_>>, |         old_payout: Option<KafkaPayout<'_>>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|     ) -> MQResult<()> { |     ) -> MQResult<()> { | ||||||
|         if let Some(negative_event) = old_payout { |         if let Some(negative_event) = old_payout { | ||||||
|             self.log_event(&KafkaEvent::old(&negative_event)) |             self.log_event(&KafkaEvent::old(&negative_event, tenant_id.clone())) | ||||||
|                 .attach_printable_lazy(|| { |                 .attach_printable_lazy(|| { | ||||||
|                     format!("Failed to add negative payout event {negative_event:?}") |                     format!("Failed to add negative payout event {negative_event:?}") | ||||||
|                 })?; |                 })?; | ||||||
|         }; |         }; | ||||||
|         self.log_event(&KafkaEvent::new(payout)) |         self.log_event(&KafkaEvent::new(payout, tenant_id.clone())) | ||||||
|             .attach_printable_lazy(|| format!("Failed to add positive payout event {payout:?}")) |             .attach_printable_lazy(|| format!("Failed to add positive payout event {payout:?}")) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     #[cfg(feature = "payouts")] |     #[cfg(feature = "payouts")] | ||||||
|     pub async fn log_payout_delete(&self, delete_old_payout: &KafkaPayout<'_>) -> MQResult<()> { |     pub async fn log_payout_delete( | ||||||
|         self.log_event(&KafkaEvent::old(delete_old_payout)) |         &self, | ||||||
|  |         delete_old_payout: &KafkaPayout<'_>, | ||||||
|  |         tenant_id: TenantID, | ||||||
|  |     ) -> MQResult<()> { | ||||||
|  |         self.log_event(&KafkaEvent::old(delete_old_payout, tenant_id.clone())) | ||||||
|             .attach_printable_lazy(|| { |             .attach_printable_lazy(|| { | ||||||
|                 format!("Failed to add negative payout event {delete_old_payout:?}") |                 format!("Failed to add negative payout event {delete_old_payout:?}") | ||||||
|             }) |             }) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Subhajit Ghosh
					Subhajit Ghosh