mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	fix(v2): Trait gating in v2 (#7223)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -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<Output = errors::CustomResult<T, errors::StorageError>> + 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, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sarthak Soni
					Sarthak Soni