mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	feat(routing): Add support to update config for elimination routing (#7938)
Co-authored-by: Spriti Aneja <spriti.aneja@juspay.in> Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com>
This commit is contained in:
		| @ -839,18 +839,42 @@ pub struct EliminationAnalyserConfig { | ||||
|     pub bucket_leak_interval_in_secs: Option<u64>, | ||||
| } | ||||
|  | ||||
| impl EliminationAnalyserConfig { | ||||
|     pub fn update(&mut self, new: Self) { | ||||
|         if let Some(bucket_size) = new.bucket_size { | ||||
|             self.bucket_size = Some(bucket_size) | ||||
|         } | ||||
|         if let Some(bucket_leak_interval_in_secs) = new.bucket_leak_interval_in_secs { | ||||
|             self.bucket_leak_interval_in_secs = Some(bucket_leak_interval_in_secs) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Default for EliminationRoutingConfig { | ||||
|     fn default() -> Self { | ||||
|         Self { | ||||
|             params: Some(vec![DynamicRoutingConfigParams::PaymentMethod]), | ||||
|             elimination_analyser_config: Some(EliminationAnalyserConfig { | ||||
|                 bucket_size: Some(5), | ||||
|                 bucket_leak_interval_in_secs: Some(2), | ||||
|                 bucket_leak_interval_in_secs: Some(60), | ||||
|             }), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl EliminationRoutingConfig { | ||||
|     pub fn update(&mut self, new: Self) { | ||||
|         if let Some(params) = new.params { | ||||
|             self.params = Some(params) | ||||
|         } | ||||
|         if let Some(new_config) = new.elimination_analyser_config { | ||||
|             self.elimination_analyser_config | ||||
|                 .as_mut() | ||||
|                 .map(|config| config.update(new_config)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)] | ||||
| pub struct SuccessBasedRoutingConfig { | ||||
|     pub params: Option<Vec<DynamicRoutingConfigParams>>, | ||||
| @ -917,6 +941,13 @@ pub struct SuccessBasedRoutingPayloadWrapper { | ||||
|     pub profile_id: common_utils::id_type::ProfileId, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct EliminationRoutingPayloadWrapper { | ||||
|     pub updated_config: EliminationRoutingConfig, | ||||
|     pub algorithm_id: common_utils::id_type::RoutingId, | ||||
|     pub profile_id: common_utils::id_type::ProfileId, | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||
| pub struct ContractBasedRoutingPayloadWrapper { | ||||
|     pub updated_config: ContractBasedRoutingConfig, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 spritianeja03
					spritianeja03