-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(routing): Use Moka cache for routing with cache invalidation #3216
Conversation
[ | ||
cache::CacheKind::Accounts( | ||
format!("{}_{}", mca.merchant_id, _profile_id).into(), | ||
), | ||
cache::CacheKind::KGraph( | ||
format!("kgraph_{}_{_profile_id}", mca.merchant_id).into(), |
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.
Feature gating for business_profile_routing
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.
we have a check for profile_id here, we seem to be throwing an error in case profile_id is not present.
let kgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| { | ||
CacheKind::KGraph( | ||
format!( | ||
"kgraph_{}_{}", | ||
merchant_account.merchant_id.clone(), | ||
profile_id, | ||
) | ||
.into(), | ||
) | ||
}); | ||
|
||
#[cfg(not(feature = "business_profile_routing"))] | ||
let kgraph_key = Some(format!("kgraph_{}", merchant_account.merchant_id.clone())); |
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.
The types for both variables do not match. Ensure that they do.
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 nitpicks. Not blockers.
47ca2d4
let kgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| { | ||
CacheKind::CGraph( | ||
format!( | ||
"kgraph_{}_{}", | ||
merchant_account.merchant_id.clone(), | ||
profile_id, | ||
) | ||
.into(), | ||
) | ||
}); |
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.
Should this have been cgraph_key
, and the format string "cgraph_{}_{}"
?
let kgraph_key = Some(CacheKind::CGraph( | ||
format!("kgraph_{}", merchant_account.merchant_id.clone()).into(), | ||
)); |
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.
Same here, should the variable name have been cgraph_key
and the format string cgraph_{}
?
Why don't we consider adding a function to generate the cgraph cache key for a specified merchant ID, and an optionally specified business profile ID (the profile ID could also be specified based on the business_profile_routing
being enabled)?
Type of Change
Description
Enabled Moka cache for routing with cache invalidation
Additional Changes
Motivation and Context
How did you test it?
Look for the pub-sub cache invalidation log
Checklist
cargo +nightly fmt --all
cargo clippy