mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	feat(euclid): add dynamic routing in core flows (#6333)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -522,22 +522,51 @@ pub struct DynamicAlgorithmWithTimestamp<T> { | ||||
|  | ||||
| #[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct DynamicRoutingAlgorithmRef { | ||||
|     pub success_based_algorithm: | ||||
|         Option<DynamicAlgorithmWithTimestamp<common_utils::id_type::RoutingId>>, | ||||
|     pub success_based_algorithm: Option<SuccessBasedAlgorithm>, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct SuccessBasedAlgorithm { | ||||
|     pub algorithm_id_with_timestamp: | ||||
|         DynamicAlgorithmWithTimestamp<common_utils::id_type::RoutingId>, | ||||
|     #[serde(default)] | ||||
|     pub enabled_feature: SuccessBasedRoutingFeatures, | ||||
| } | ||||
|  | ||||
| impl SuccessBasedAlgorithm { | ||||
|     pub fn update_enabled_features(&mut self, feature_to_enable: SuccessBasedRoutingFeatures) { | ||||
|         self.enabled_feature = feature_to_enable | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl DynamicRoutingAlgorithmRef { | ||||
|     pub fn update_algorithm_id(&mut self, new_id: common_utils::id_type::RoutingId) { | ||||
|         self.success_based_algorithm = Some(DynamicAlgorithmWithTimestamp { | ||||
|             algorithm_id: Some(new_id), | ||||
|             timestamp: common_utils::date_time::now_unix_timestamp(), | ||||
|     pub fn update_algorithm_id( | ||||
|         &mut self, | ||||
|         new_id: common_utils::id_type::RoutingId, | ||||
|         enabled_feature: SuccessBasedRoutingFeatures, | ||||
|     ) { | ||||
|         self.success_based_algorithm = Some(SuccessBasedAlgorithm { | ||||
|             algorithm_id_with_timestamp: DynamicAlgorithmWithTimestamp { | ||||
|                 algorithm_id: Some(new_id), | ||||
|                 timestamp: common_utils::date_time::now_unix_timestamp(), | ||||
|             }, | ||||
|             enabled_feature, | ||||
|         }) | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] | ||||
| pub struct ToggleSuccessBasedRoutingQuery { | ||||
|     pub status: bool, | ||||
|     pub enable: SuccessBasedRoutingFeatures, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, ToSchema)] | ||||
| #[serde(rename_all = "snake_case")] | ||||
| pub enum SuccessBasedRoutingFeatures { | ||||
|     Metrics, | ||||
|     DynamicConnectorSelection, | ||||
|     #[default] | ||||
|     None, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)] | ||||
| @ -551,7 +580,7 @@ pub struct SuccessBasedRoutingUpdateConfigQuery { | ||||
| #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] | ||||
| pub struct ToggleSuccessBasedRoutingWrapper { | ||||
|     pub profile_id: common_utils::id_type::ProfileId, | ||||
|     pub status: bool, | ||||
|     pub feature_to_enable: SuccessBasedRoutingFeatures, | ||||
| } | ||||
|  | ||||
| #[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Prajjwal Kumar
					Prajjwal Kumar