feat(routing): Integrate global success rates (#6950)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sarthak Soni
2025-01-21 17:14:14 +05:30
committed by GitHub
parent 100a1783ac
commit 39d2d6c438
11 changed files with 196 additions and 17 deletions

View File

@ -779,6 +779,7 @@ impl Default for SuccessBasedRoutingConfig {
duration_in_mins: Some(5),
max_total_count: Some(2),
}),
specificity_level: SuccessRateSpecificityLevel::default(),
}),
}
}
@ -801,6 +802,8 @@ pub struct SuccessBasedRoutingConfigBody {
pub default_success_rate: Option<f64>,
pub max_aggregates_size: Option<u32>,
pub current_block_threshold: Option<CurrentBlockThreshold>,
#[serde(default)]
pub specificity_level: SuccessRateSpecificityLevel,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
@ -809,6 +812,14 @@ pub struct CurrentBlockThreshold {
pub max_total_count: Option<u64>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum SuccessRateSpecificityLevel {
#[default]
Merchant,
Global,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SuccessBasedRoutingPayloadWrapper {
pub updated_config: SuccessBasedRoutingConfig,
@ -849,6 +860,7 @@ impl SuccessBasedRoutingConfigBody {
.as_mut()
.map(|threshold| threshold.update(current_block_threshold));
}
self.specificity_level = new.specificity_level
}
}