From f94eb06f107011dadfb862b09f08308c06d0ff26 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Tue, 14 Oct 2025 06:05:26 +0000 Subject: [PATCH] chore: run formatter --- crates/router/src/core/payments/helpers.rs | 29 ++++++++++--------- .../src/core/unified_connector_service.rs | 11 ++++--- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 69408f2ede..a140dcd3a4 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -2220,7 +2220,8 @@ pub async fn should_execute_based_on_rollout( match db.find_config_by_key(config_key).await { Ok(rollout_config) => { // Try to parse as JSON first (new format), fallback to float (legacy format) - let config_result = match serde_json::from_str::(&rollout_config.config) { + let config_result = match serde_json::from_str::(&rollout_config.config) + { Ok(config) => Ok(config), Err(_) => { // Fallback to legacy format (simple float) @@ -2244,15 +2245,16 @@ pub async fn should_execute_based_on_rollout( rollout_percent = config.rollout_percent, "Rollout percent out of bounds. Must be between 0.0 and 1.0" ); - let proxy_override = if config.http_url.is_some() || config.https_url.is_some() { - Some(ProxyOverride { - http_url: config.http_url, - https_url: config.https_url, - }) - } else { - None - }; - + let proxy_override = + if config.http_url.is_some() || config.https_url.is_some() { + Some(ProxyOverride { + http_url: config.http_url, + https_url: config.https_url, + }) + } else { + None + }; + return Ok(RolloutExecutionResult { should_execute: false, proxy_override, @@ -2261,9 +2263,10 @@ pub async fn should_execute_based_on_rollout( let sampled_value: f64 = rand::thread_rng().gen_range(0.0..1.0); let should_execute = sampled_value < config.rollout_percent; - + // Create proxy override if URLs are available - let proxy_override = if config.http_url.is_some() || config.https_url.is_some() { + let proxy_override = if config.http_url.is_some() || config.https_url.is_some() + { if let Some(ref http_url) = config.http_url { logger::info!(http_url = %http_url, "Using HTTP proxy URL from rollout config"); } @@ -2291,7 +2294,7 @@ pub async fn should_execute_based_on_rollout( }) } } - }, + } Err(err) => { logger::error!(error = ?err, "Failed to fetch rollout config from DB"); Ok(RolloutExecutionResult { diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs index e4dcea8a55..aea9400147 100644 --- a/crates/router/src/core/unified_connector_service.rs +++ b/crates/router/src/core/unified_connector_service.rs @@ -49,8 +49,8 @@ use crate::{ errors::{self, RouterResult}, payments::{ helpers::{ - is_ucs_enabled, should_execute_based_on_rollout, MerchantConnectorAccountType, - RolloutExecutionResult, ProxyOverride, EffectiveProxyConfig, ProxyConfig, + is_ucs_enabled, should_execute_based_on_rollout, EffectiveProxyConfig, + MerchantConnectorAccountType, ProxyConfig, ProxyOverride, RolloutExecutionResult, }, OperationSessionGetters, OperationSessionSetters, }, @@ -167,12 +167,11 @@ where let shadow_rollout_key = format!("{}_shadow", rollout_key); let rollout_result = should_execute_based_on_rollout(state, &rollout_key).await?; - let shadow_rollout_result = - should_execute_based_on_rollout(state, &shadow_rollout_key).await?; - + let shadow_rollout_result = should_execute_based_on_rollout(state, &shadow_rollout_key).await?; + let rollout_enabled = rollout_result.should_execute; let shadow_rollout_enabled = shadow_rollout_result.should_execute; - + // Log proxy URLs if available if let Some(ref proxy_override) = rollout_result.proxy_override { router_env::logger::info!(