New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(db): Add TenantID field to KafkaEvent struct #4598
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you share screenshots of the generated events from the kafka-ui ?
crates/router/src/services/kafka.rs
Outdated
))) | ||
self.log_event(&KafkaEvent::old( | ||
&KafkaPaymentAttempt::from_storage(&negative_event), | ||
TenantID("default".to_string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use the tenant_id stored in the kafkastore instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have used that TenantID here only ... I have imported that at the top in kafka.rs file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that can you add a parameter in the log_payment_attempt function to accept a tenant_id and use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes done that!
@@ -30,6 +30,7 @@ use crate::types::storage::Dispute; | |||
|
|||
// Using message queue result here to avoid confusion with Kafka result provided by library | |||
pub type MQResult<T> = CustomResult<T, KafkaError>; | |||
use crate::db::kafka_store::TenantID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the line @lsampras
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor refactors needed,
Also can you run the formatting & clippy checks locally there might be some linting problems here.
Would also prefer if you are able to run it locally and share screenshots for the same
crates/router/src/db/kafka_store.rs
Outdated
@@ -1109,7 +1109,7 @@ impl PaymentAttemptInterface for KafkaStore { | |||
|
|||
if let Err(er) = self | |||
.kafka_producer | |||
.log_payment_attempt(&attempt, None) | |||
.log_payment_attempt(&attempt, None, TenantID("default".to_string())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.log_payment_attempt(&attempt, None, TenantID("default".to_string())) | |
.log_payment_attempt(&attempt, None, self.tenant_id) |
Can we use the tenant_id stored in KafkaStore
struct as such
crates/router/src/services/kafka.rs
Outdated
self.log_event(&KafkaEvent::old( | ||
&KafkaPaymentAttempt::from_storage(delete_old_attempt), | ||
TenantID("default".to_string()), | ||
)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we follow the same pattern as we did for log_payment_attempt
function for every other usage as well?
there shouldn't be any new initializations of TenantID
in this PR, since it is already defined in KafkaStore which is what we'll be using instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I this commit solves this issue,
let me know if further changes needed. @lsampras
…ducer impl and fixed lint issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@subhajit20 the code changes look good, Will you be able to test this out locally & share the screenshots of updated Kafka events?
Thanks for the contribution @subhajit20. |
Type of Change
#4595
Description
Additional Changes
Motivation and Context
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy