diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs index a08f80354b..6a21dddc06 100644 --- a/crates/router/src/core/routing/helpers.rs +++ b/crates/router/src/core/routing/helpers.rs @@ -2,9 +2,11 @@ //! //! Functions that are used to perform the retrieval of merchant's //! routing dict, configs, defaults +use std::fmt::Debug; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] use std::str::FromStr; -use std::{fmt::Debug, sync::Arc}; +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] +use std::sync::Arc; use api_models::routing as routing_types; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] @@ -13,7 +15,7 @@ use common_utils::{ext_traits::Encode, id_type, types::keymanager::KeyManagerSta use diesel_models::configs; #[cfg(all(feature = "v1", feature = "dynamic_routing"))] use diesel_models::dynamic_routing_stats::DynamicRoutingStatsNew; -#[cfg(feature = "v1")] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] use diesel_models::routing_algorithm; use error_stack::ResultExt; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] @@ -21,14 +23,16 @@ use external_services::grpc_client::dynamic_routing::{ contract_routing_client::ContractBasedDynamicRouting, success_rate_client::SuccessBasedDynamicRouting, }; -#[cfg(feature = "v1")] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] use hyperswitch_domain_models::api::ApplicationResponse; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] use router_env::logger; -#[cfg(any(feature = "dynamic_routing", feature = "v1"))] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] use router_env::{instrument, tracing}; use rustc_hash::FxHashSet; -use storage_impl::redis::cache::{self, Cacheable}; +use storage_impl::redis::cache; +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] +use storage_impl::redis::cache::Cacheable; #[cfg(all(feature = "dynamic_routing", feature = "v1"))] use crate::db::errors::StorageErrorExt; @@ -41,7 +45,7 @@ use crate::{ types::{domain, storage}, utils::StringExt, }; -#[cfg(feature = "v1")] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] use crate::{core::metrics as core_metrics, types::transformers::ForeignInto}; pub const SUCCESS_BASED_DYNAMIC_ROUTING_ALGORITHM: &str = "Success rate based dynamic routing algorithm"; @@ -566,6 +570,7 @@ pub fn get_default_config_key( } } +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] #[async_trait::async_trait] pub trait DynamicRoutingCache { async fn get_cached_dynamic_routing_config_for_profile( @@ -584,6 +589,7 @@ pub trait DynamicRoutingCache { Fut: futures::Future> + Send; } +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] #[async_trait::async_trait] impl DynamicRoutingCache for routing_types::SuccessBasedRoutingConfig { async fn get_cached_dynamic_routing_config_for_profile( @@ -620,6 +626,7 @@ impl DynamicRoutingCache for routing_types::SuccessBasedRoutingConfig { } } +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] #[async_trait::async_trait] impl DynamicRoutingCache for routing_types::ContractBasedRoutingConfig { async fn get_cached_dynamic_routing_config_for_profile( @@ -1502,7 +1509,7 @@ where Ok(ApplicationResponse::Json(updated_routing_record)) } -#[cfg(feature = "v1")] +#[cfg(all(feature = "dynamic_routing", feature = "v1"))] #[instrument(skip_all)] pub async fn default_specific_dynamic_routing_setup( state: &SessionState,