Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(core): fix the multitenancy prefix in routing cache (#4963)
Amisha Prabhatb42052269455
diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rsindex 4a92dbbc81..f732f8a792 100644--- a/crates/router/src/core/payment_methods/utils.rs+++ b/crates/router/src/core/payment_methods/utils.rs@@ -45,7 +45,7 @@ pub async fn get_merchant_pm_filter_graph<'a>(.get_val::<Arc<hyperswitch_constraint_graph::ConstraintGraph<'_, dir::DirValue>>>(CacheKey {key: key.to_string(),- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),},).await@@ -61,7 +61,7 @@ pub async fn refresh_pm_filters_cache(.push(CacheKey {key: key.to_string(),- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),},pm_filter_graph.clone(),)diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rsindex 15eda58c91..fa64d9882d 100644--- a/crates/router/src/core/payments/routing.rs+++ b/crates/router/src/core/payments/routing.rs@@ -368,7 +368,7 @@ async fn ensure_algorithm_cached_v1(let cached_algorithm = ROUTING_CACHE.get_val::<Arc<CachedAlgorithm>>(CacheKey {key: key.clone(),- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),}).await;@@ -490,7 +490,7 @@ pub async fn refresh_routing_cache_v1(.push(CacheKey {key,- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),},arc_cached_algorithm.clone(),)@@ -567,7 +567,7 @@ pub async fn get_merchant_cgraph<'a>(.get_val::<Arc<hyperswitch_constraint_graph::ConstraintGraph<'_, euclid_dir::DirValue>>>(CacheKey {key: key.clone(),- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),},).await;@@ -668,7 +668,7 @@ pub async fn refresh_cgraph_cache<'a>(.push(CacheKey {key,- prefix: state.tenant.clone(),+ prefix: state.tenant.redis_key_prefix.clone(),},Arc::clone(&cgraph),)diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 8d88d9c4b2..92ca3c264f 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -18,6 +18,7 @@ use scheduler::SchedulerInterface;use storage_impl::{config::TenantConfig, redis::RedisStore, MockDb};use tokio::sync::oneshot;+use self::settings::Tenant;#[cfg(feature = "olap")]use super::blocklist;#[cfg(feature = "dummy_connector")]@@ -85,7 +86,7 @@ pub struct SessionState {pub file_storage_client: Arc<dyn FileStorageInterface>,pub request_id: Option<RequestId>,pub base_url: String,- pub tenant: String,+ pub tenant: Tenant,#[cfg(feature = "olap")]pub opensearch_client: Arc<OpenSearchClient>,}@@ -380,6 +381,7 @@ impl AppState {whereF: FnOnce() -> E + Copy,{+ let tenant_conf = self.conf.multitenancy.get_tenant(tenant).ok_or_else(err)?;Ok(SessionState {store: self.stores.get(tenant).ok_or_else(err)?.clone(),global_store: self.global_store.clone(),@@ -390,15 +392,8 @@ impl AppState {pool: self.pools.get(tenant).ok_or_else(err)?.clone(),file_storage_client: self.file_storage_client.clone(),request_id: self.request_id,- base_url: self- .conf- .multitenancy- .get_tenant(tenant)- .ok_or_else(err)?- .clone()- .base_url- .clone(),- tenant: tenant.to_string().clone(),+ base_url: tenant_conf.base_url.clone(),+ tenant: tenant_conf.clone(),#[cfg(feature = "email")]email_client: Arc::clone(&self.email_client),#[cfg(feature = "olap")]