Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(dynamic_routing): add support for shuffle on tie flag to success_based routing (#8241)

Chethan Raoc72d365fdeac
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index f126039079..cfe8027c87 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -23862,6 +23862,10 @@
"type": "number",
"format": "double",
"nullable": true
+ },
+ "shuffle_on_tie_during_exploitation": {
+ "type": "boolean",
+ "nullable": true
}
}
},
diff --git a/api-reference/hyperswitch_intelligent_router_open_api_spec.yml b/api-reference/hyperswitch_intelligent_router_open_api_spec.yml
index 7372a083b8..c3c1d3458c 100644
--- a/api-reference/hyperswitch_intelligent_router_open_api_spec.yml
+++ b/api-reference/hyperswitch_intelligent_router_open_api_spec.yml
@@ -45,6 +45,7 @@ paths:
default_success_rate: 0.95
specificity_level: ENTITY
exploration_percent: 20.0
+ shuffle_on_tie_during_exploitation: true
responses:
"200":
description: Success rate calculated successfully
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index d12b7b3be1..7bb7f3b382 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -28802,6 +28802,10 @@
"type": "number",
"format": "double",
"nullable": true
+ },
+ "shuffle_on_tie_during_exploitation": {
+ "type": "boolean",
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs
index ed1915764c..aea14c23fe 100644
--- a/crates/api_models/src/routing.rs
+++ b/crates/api_models/src/routing.rs
@@ -1016,6 +1016,7 @@ impl Default for SuccessBasedRoutingConfig {
}),
specificity_level: SuccessRateSpecificityLevel::default(),
exploration_percent: Some(20.0),
+ shuffle_on_tie_during_exploitation: Some(false),
}),
decision_engine_configs: None,
}
@@ -1044,6 +1045,7 @@ pub struct SuccessBasedRoutingConfigBody {
#[serde(default)]
pub specificity_level: SuccessRateSpecificityLevel,
pub exploration_percent: Option<f64>,
+ pub shuffle_on_tie_during_exploitation: Option<bool>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]
@@ -1173,6 +1175,9 @@ impl SuccessBasedRoutingConfigBody {
if let Some(exploration_percent) = new.exploration_percent {
self.exploration_percent = Some(exploration_percent);
}
+ if let Some(shuffle_on_tie_during_exploitation) = new.shuffle_on_tie_during_exploitation {
+ self.shuffle_on_tie_during_exploitation = Some(shuffle_on_tie_during_exploitation);
+ }
}
}
diff --git a/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs b/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
index b63f435327..00f3e1f159 100644
--- a/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
+++ b/crates/external_services/src/grpc_client/dynamic_routing/success_rate_client.rs
@@ -291,6 +291,7 @@ impl ForeignTryFrom<SuccessBasedRoutingConfigBody> for CalSuccessRateConfig {
SuccessRateSpecificityLevel::Global => Some(ProtoSpecificityLevel::Global.into()),
},
exploration_percent: config.exploration_percent,
+ shuffle_on_tie_during_exploitation: config.shuffle_on_tie_during_exploitation,
})
}
}
diff --git a/proto/success_rate.proto b/proto/success_rate.proto
index efdd439cac..cdcde99fa8 100644
--- a/proto/success_rate.proto
+++ b/proto/success_rate.proto
@@ -24,6 +24,7 @@ message CalSuccessRateConfig {
double default_success_rate = 2;
optional SuccessRateSpecificityLevel specificity_level = 3;
optional double exploration_percent = 4;
+ optional bool shuffle_on_tie_during_exploitation = 5;
}
enum SuccessRateSpecificityLevel {
@@ -78,13 +79,13 @@ message UpdateSuccessRateWindowResponse {
UpdationStatus status = 1;
}
- // API-3 types
+// API-3 types
message InvalidateWindowsRequest {
string id = 1;
}
message InvalidateWindowsResponse {
- enum InvalidationStatus {
+ enum InvalidationStatus {
WINDOW_INVALIDATION_SUCCEEDED = 0;
WINDOW_INVALIDATION_FAILED = 1;
}