Skip to content
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(conditional_configs): refactor conditional_configs to use Moka Cache instead of Static Cache #4814

Merged
merged 24 commits into from
Jun 11, 2024

Conversation

Aprabhat19
Copy link
Contributor

@Aprabhat19 Aprabhat19 commented May 29, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

refactor conditional_configs to use Moka Cache instead of Static Cache

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Cannot be tested

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Aprabhat19 Aprabhat19 self-assigned this May 29, 2024
@Aprabhat19 Aprabhat19 requested a review from a team as a code owner May 29, 2024 11:36
@Aprabhat19 Aprabhat19 added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-routing Area: Routing labels May 29, 2024
@Aprabhat19 Aprabhat19 requested review from a team as code owners May 30, 2024 11:57
Comment on lines 386 to 390
let value_to_cache = || async {
VirInterpreterBackendCacheWrapper::try_from(record)
.change_context(errors::StorageError::ValueNotFound("Program".to_string()))
.attach_printable("Error initializing DSL interpreter backend")
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the DB call to fetch the config (and thus parsing the record) within the closure, to avoid unnecessary DB calls.

Comment on lines 48 to 52
let find_key_from_db = || async {
backend::VirInterpreterBackend::with_program(rec.program)
.change_context(ConfigError::DslBackendInitError)
.attach_printable("Error initializing DSL interpreter backend")?;
CONF_CACHE
.save(key, interpreter, timestamp)
.change_context(ConfigError::DslCachePoisoned)
.attach_printable("Error saving DSL to cache")?;
Ok(())
.change_context(errors::StorageError::ValueNotFound("Program".to_string()))
.attach_printable("Error initializing DSL interpreter backend")
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar change can be done here.

@@ -517,7 +517,7 @@ async fn publish_and_redact_merchant_account_cache(
let kgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let kgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| {
let cgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| {

@@ -527,7 +527,7 @@ async fn publish_and_redact_merchant_account_cache(

#[cfg(not(feature = "business_profile_routing"))]
let kgraph_key = Some(CacheKind::CGraph(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let kgraph_key = Some(CacheKind::CGraph(
let cgraph_key = Some(CacheKind::CGraph(

SanchithHegde
SanchithHegde previously approved these changes Jun 5, 2024
Copy link
Member

@vspecky vspecky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add cache invalidation logic. When the 3ds decision manager config is updated or deleted, we should invalidate the cache of of all pods. Same for surcharge.

hrithikesh026
hrithikesh026 previously approved these changes Jun 5, 2024
Copy link
Contributor

@hrithikesh026 hrithikesh026 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surcharge Decision Configs Related changes LGTM

@Aprabhat19 Aprabhat19 dismissed stale reviews from hrithikesh026 and SanchithHegde via 1604e92 June 6, 2024 09:59
crates/router/src/core/routing/helpers.rs Outdated Show resolved Hide resolved
Copy link
Member

@vspecky vspecky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 11, 2024
Merged via the queue into main with commit 4d0c893 Jun 11, 2024
14 checks passed
@likhinbopanna likhinbopanna deleted the cache-decision-manager branch June 11, 2024 08:01
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Moka Cache instead of Static Cache for 3DS Decision Manager and Surcharge Configs
5 participants