mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
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:
@ -23374,9 +23374,13 @@
|
||||
},
|
||||
"specificity_level": {
|
||||
"$ref": "#/components/schemas/SuccessRateSpecificityLevel"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
"exploration_percent": {
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"SuccessRateSpecificityLevel": {
|
||||
"type": "string",
|
||||
|
||||
@ -44,6 +44,7 @@ paths:
|
||||
min_aggregates_size: 5
|
||||
default_success_rate: 0.95
|
||||
specificity_level: ENTITY
|
||||
exploration_percent: 20.0
|
||||
responses:
|
||||
"200":
|
||||
description: Success rate calculated successfully
|
||||
@ -758,6 +759,17 @@ components:
|
||||
items:
|
||||
$ref: "#/components/schemas/LabelWithScore"
|
||||
description: List of labels with their calculated success rates
|
||||
routing_approach:
|
||||
$ref: "#/components/schemas/RoutingApproach"
|
||||
|
||||
RoutingApproach:
|
||||
type: string
|
||||
description: >
|
||||
Defines the routing approach based on the success rate calculation.
|
||||
enum:
|
||||
- EXPLORATION
|
||||
- EXPLOITATION
|
||||
example: EXPLOITATION
|
||||
|
||||
UpdateSuccessRateWindowRequest:
|
||||
type: object
|
||||
|
||||
@ -27396,9 +27396,13 @@
|
||||
},
|
||||
"specificity_level": {
|
||||
"$ref": "#/components/schemas/SuccessRateSpecificityLevel"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
"exploration_percent": {
|
||||
"type": "number",
|
||||
"format": "double",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"SuccessRateSpecificityLevel": {
|
||||
"type": "string",
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -290,6 +290,7 @@ impl ForeignTryFrom<SuccessBasedRoutingConfigBody> for CalSuccessRateConfig {
|
||||
SuccessRateSpecificityLevel::Merchant => Some(ProtoSpecificityLevel::Entity.into()),
|
||||
SuccessRateSpecificityLevel::Global => Some(ProtoSpecificityLevel::Global.into()),
|
||||
},
|
||||
exploration_percent: config.exploration_percent,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1776,10 +1776,7 @@ pub async fn perform_decide_gateway_call_with_open_router(
|
||||
))?;
|
||||
|
||||
if let Some(gateway_priority_map) = decided_gateway.gateway_priority_map {
|
||||
logger::debug!(
|
||||
"open_router decide_gateway call response: {:?}",
|
||||
gateway_priority_map
|
||||
);
|
||||
logger::debug!(gateway_priority_map=?gateway_priority_map, routing_approach=decided_gateway.routing_approach, "open_router decide_gateway call response");
|
||||
routable_connectors.sort_by(|connector_choice_a, connector_choice_b| {
|
||||
let connector_choice_a_score = gateway_priority_map
|
||||
.get(&connector_choice_a.to_string())
|
||||
|
||||
@ -23,6 +23,7 @@ message CalSuccessRateConfig {
|
||||
uint32 min_aggregates_size = 1;
|
||||
double default_success_rate = 2;
|
||||
optional SuccessRateSpecificityLevel specificity_level = 3;
|
||||
optional double exploration_percent = 4;
|
||||
}
|
||||
|
||||
enum SuccessRateSpecificityLevel {
|
||||
@ -32,6 +33,12 @@ enum SuccessRateSpecificityLevel {
|
||||
|
||||
message CalSuccessRateResponse {
|
||||
repeated LabelWithScore labels_with_score = 1;
|
||||
RoutingApproach routing_approach = 2;
|
||||
}
|
||||
|
||||
enum RoutingApproach {
|
||||
EXPLORATION = 0;
|
||||
EXPLOITATION = 1;
|
||||
}
|
||||
|
||||
message LabelWithScore {
|
||||
|
||||
Reference in New Issue
Block a user