refactor(success_based): add support for exploration (#8158)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Chethan Rao
2025-05-27 22:46:44 +05:30
committed by GitHub
parent b7c5f1f276
commit 3eb94d9a3d
8 changed files with 40 additions and 10 deletions

View File

@ -62,6 +62,7 @@ pub struct PaymentInfo {
pub struct DecidedGateway {
pub gateway_priority_map: Option<HashMap<String, f64>>,
pub debit_routing_output: Option<DebitRoutingOutput>,
pub routing_approach: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]

View File

@ -965,6 +965,7 @@ impl Default for SuccessBasedRoutingConfig {
max_total_count: Some(5),
}),
specificity_level: SuccessRateSpecificityLevel::default(),
exploration_percent: Some(20.0),
}),
decision_engine_configs: None,
}
@ -985,7 +986,6 @@ pub enum DynamicRoutingConfigParams {
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct SuccessBasedRoutingConfigBody {
pub min_aggregates_size: Option<u32>,
pub default_success_rate: Option<f64>,
@ -993,6 +993,7 @@ pub struct SuccessBasedRoutingConfigBody {
pub current_block_threshold: Option<CurrentBlockThreshold>,
#[serde(default)]
pub specificity_level: SuccessRateSpecificityLevel,
pub exploration_percent: Option<f64>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
@ -1118,7 +1119,10 @@ impl SuccessBasedRoutingConfigBody {
.as_mut()
.map(|threshold| threshold.update(current_block_threshold));
}
self.specificity_level = new.specificity_level
self.specificity_level = new.specificity_level;
if let Some(exploration_percent) = new.exploration_percent {
self.exploration_percent = Some(exploration_percent);
}
}
}