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
feat(ucs): send x-proxy-name header so UCS selects the proxy based on… (#12530)
gopikrishna000c6104704e77e
diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rsindex cd27d7ea59..967c018e11 100644--- a/crates/common_utils/src/consts.rs+++ b/crates/common_utils/src/consts.rs@@ -178,6 +178,9 @@ pub const X_SUB_FLOW_NAME: &str = "x-sub-flow";/// Unified Connector Service Modepub const X_UNIFIED_CONNECTOR_SERVICE_MODE: &str = "x-shadow-mode";+/// Proxy name for UCS to select the proxy to route the request through+pub const X_PROXY_NAME: &str = "x-proxy-name";+/// Config Override Header for UCSpub const X_CONFIG_OVERRIDE: &str = "x-config-override";diff --git a/crates/external_services/src/grpc_client.rs b/crates/external_services/src/grpc_client.rsindex 6ee19fffe3..77c21e753b 100644--- a/crates/external_services/src/grpc_client.rs+++ b/crates/external_services/src/grpc_client.rs@@ -168,6 +168,8 @@ pub struct GrpcHeadersUcs {resource_id: Option<ucs_types::UcsResourceId>,shadow_mode: Option<bool>,+ /// Proxy name for UCS to select the proxy to route the request through+ proxy_name: Option<&'static str>,/// Config override as JSON string to pass to UCSconfig_override: Option<String>,}@@ -181,6 +183,7 @@ pub type GrpcHeadersUcsBuilderInitial = GrpcHeadersUcsBuilder<((),(),(Option<bool>,),+ (Option<&'static str>,),(Option<String>,),)>;/// Type aliase for GrpcHeaders builder in intermediate stage@@ -192,6 +195,7 @@ pub type GrpcHeadersUcsBuilderFinal = GrpcHeadersUcsBuilder<((Option<ucs_types::UcsReferenceId>,),(Option<ucs_types::UcsResourceId>,),(Option<bool>,),+ (Option<&'static str>,),(Option<String>,),)>;diff --git a/crates/external_services/src/grpc_client/unified_connector_service.rs b/crates/external_services/src/grpc_client/unified_connector_service.rsindex 307656c3bb..6ef8509e31 100644--- a/crates/external_services/src/grpc_client/unified_connector_service.rs+++ b/crates/external_services/src/grpc_client/unified_connector_service.rs@@ -1333,6 +1333,7 @@ fn build_grpc_headers_internal(merchant_reference_id,resource_id,shadow_mode,+ proxy_name,config_override,} = grpc_headers;@@ -1449,6 +1450,13 @@ fn build_grpc_headers_internal();}+ if let Some(proxy_name) = proxy_name {+ metadata.append(+ common_utils_consts::X_PROXY_NAME,+ parse(common_utils_consts::X_PROXY_NAME, proxy_name)?,+ );+ }+if let Some(config_override) = config_override {metadata.append(common_utils_consts::X_CONFIG_OVERRIDE,diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 9e8e08a75d..aff6691231 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -186,6 +186,12 @@ impl SessionState {ExecutionMode::Shadow => Some(true),ExecutionMode::NotApplicable => None,};+ // UCS selects the proxy to route through based on this header+ let proxy_name = match unified_connector_service_execution_mode {+ ExecutionMode::Primary => Some("primary"),+ ExecutionMode::Shadow => Some("shadow"),+ ExecutionMode::NotApplicable => None,+ };// For shadow mode, disable event publishing in UCSlet config_override = match unified_connector_service_execution_mode {ExecutionMode::Shadow => Some(@@ -202,6 +208,7 @@ impl SessionState {.tenant_id(tenant_id).request_id(request_id).shadow_mode(shadow_mode)+ .proxy_name(proxy_name).config_override(config_override)}#[cfg(all(feature = "revenue_recovery", feature = "v2"))]