Skip to content

Commit 4d36be8

Browse files
Sarthak1799hyperswitch-bot[bot]prajjwalkumar17
authored
refactor(routing): Routing events core refactor (#8323)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: prajjwalkumar17 <[email protected]>
1 parent 7f6f4c4 commit 4d36be8

File tree

6 files changed

+1534
-739
lines changed

6 files changed

+1534
-739
lines changed

crates/api_models/src/open_router.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ pub struct PaymentInfo {
5858
// cardSwitchProvider: Option<Secret<String>>,
5959
}
6060

61-
#[derive(Debug, Serialize, Deserialize, PartialEq)]
61+
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
6262
pub struct DecidedGateway {
6363
pub gateway_priority_map: Option<HashMap<String, f64>>,
6464
pub debit_routing_output: Option<DebitRoutingOutput>,
6565
pub routing_approach: String,
6666
}
6767

68-
#[derive(Debug, Serialize, Deserialize, PartialEq)]
68+
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
6969
pub struct DebitRoutingOutput {
7070
pub co_badged_card_networks: Vec<common_enums::CardNetwork>,
7171
pub issuer_country: common_enums::CountryAlpha2,
@@ -121,7 +121,7 @@ pub struct DebitRoutingRequestData {
121121
pub card_type: common_enums::CardType,
122122
}
123123

124-
#[derive(Debug, Serialize, Deserialize)]
124+
#[derive(Debug, Serialize, Deserialize, Clone)]
125125
pub struct ErrorResponse {
126126
pub status: String,
127127
pub error_code: String,
@@ -132,7 +132,7 @@ pub struct ErrorResponse {
132132
pub is_dynamic_mga_enabled: bool,
133133
}
134134

135-
#[derive(Debug, Serialize, Deserialize)]
135+
#[derive(Debug, Serialize, Deserialize, Clone)]
136136
pub struct UnifiedError {
137137
pub code: String,
138138
pub user_message: String,

crates/api_models/src/routing.rs

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,160 +1384,6 @@ impl std::fmt::Display for RoutingApproach {
13841384
}
13851385
}
13861386
}
1387-
1388-
#[derive(Clone, Debug, Serialize, Deserialize)]
1389-
#[serde(rename_all = "snake_case")]
1390-
pub struct BucketInformationEventResponse {
1391-
pub is_eliminated: bool,
1392-
pub bucket_name: Vec<String>,
1393-
}
1394-
1395-
#[derive(Clone, Debug, Serialize, Deserialize)]
1396-
#[serde(rename_all = "snake_case")]
1397-
pub struct EliminationInformationEventResponse {
1398-
pub entity: Option<BucketInformationEventResponse>,
1399-
pub global: Option<BucketInformationEventResponse>,
1400-
}
1401-
1402-
#[derive(Clone, Debug, Serialize, Deserialize)]
1403-
#[serde(rename_all = "snake_case")]
1404-
pub struct LabelWithStatusEliminationEventResponse {
1405-
pub label: String,
1406-
pub elimination_information: Option<EliminationInformationEventResponse>,
1407-
}
1408-
1409-
#[derive(Clone, Debug, Serialize, Deserialize)]
1410-
#[serde(rename_all = "snake_case")]
1411-
pub struct EliminationEventResponse {
1412-
pub labels_with_status: Vec<LabelWithStatusEliminationEventResponse>,
1413-
}
1414-
1415-
#[derive(Clone, Debug, Serialize, Deserialize)]
1416-
#[serde(rename_all = "snake_case")]
1417-
pub struct ScoreDataEventResponse {
1418-
pub score: f64,
1419-
pub label: String,
1420-
pub current_count: u64,
1421-
}
1422-
1423-
#[derive(Clone, Debug, Serialize, Deserialize)]
1424-
#[serde(rename_all = "snake_case")]
1425-
pub struct CalContractScoreEventResponse {
1426-
pub labels_with_score: Vec<ScoreDataEventResponse>,
1427-
}
1428-
1429-
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
1430-
#[serde(rename_all = "snake_case")]
1431-
pub struct CalGlobalSuccessRateConfigEventRequest {
1432-
pub entity_min_aggregates_size: u32,
1433-
pub entity_default_success_rate: f64,
1434-
}
1435-
1436-
#[derive(Clone, Debug, Serialize, Deserialize)]
1437-
#[serde(rename_all = "snake_case")]
1438-
pub struct CalGlobalSuccessRateEventRequest {
1439-
pub entity_id: String,
1440-
pub entity_params: String,
1441-
pub entity_labels: Vec<String>,
1442-
pub global_labels: Vec<String>,
1443-
pub config: Option<CalGlobalSuccessRateConfigEventRequest>,
1444-
}
1445-
1446-
#[derive(Clone, Debug, Serialize, Deserialize)]
1447-
#[serde(rename_all = "snake_case")]
1448-
pub struct UpdateSuccessRateWindowConfig {
1449-
pub max_aggregates_size: Option<u32>,
1450-
pub current_block_threshold: Option<CurrentBlockThreshold>,
1451-
}
1452-
1453-
#[derive(Clone, Debug, Serialize, Deserialize)]
1454-
#[serde(rename_all = "snake_case")]
1455-
pub struct UpdateLabelWithStatusEventRequest {
1456-
pub label: String,
1457-
pub status: bool,
1458-
}
1459-
1460-
#[derive(Clone, Debug, Serialize, Deserialize)]
1461-
#[serde(rename_all = "snake_case")]
1462-
pub struct UpdateSuccessRateWindowEventRequest {
1463-
pub id: String,
1464-
pub params: String,
1465-
pub labels_with_status: Vec<UpdateLabelWithStatusEventRequest>,
1466-
pub config: Option<UpdateSuccessRateWindowConfig>,
1467-
pub global_labels_with_status: Vec<UpdateLabelWithStatusEventRequest>,
1468-
}
1469-
1470-
#[derive(Clone, Debug, Serialize, Deserialize)]
1471-
#[serde(rename_all = "snake_case")]
1472-
pub struct UpdateSuccessRateWindowEventResponse {
1473-
pub status: UpdationStatusEventResponse,
1474-
}
1475-
1476-
#[derive(Clone, Debug, Serialize, Deserialize)]
1477-
#[serde(rename_all = "snake_case")]
1478-
pub enum UpdationStatusEventResponse {
1479-
WindowUpdationSucceeded,
1480-
WindowUpdationFailed,
1481-
}
1482-
1483-
#[derive(Clone, Debug, Serialize, Deserialize)]
1484-
#[serde(rename_all = "snake_case")]
1485-
pub struct LabelWithBucketNameEventRequest {
1486-
pub label: String,
1487-
pub bucket_name: String,
1488-
}
1489-
1490-
#[derive(Clone, Debug, Serialize, Deserialize)]
1491-
#[serde(rename_all = "snake_case")]
1492-
pub struct UpdateEliminationBucketEventRequest {
1493-
pub id: String,
1494-
pub params: String,
1495-
pub labels_with_bucket_name: Vec<LabelWithBucketNameEventRequest>,
1496-
pub config: Option<EliminationRoutingEventBucketConfig>,
1497-
}
1498-
1499-
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1500-
#[serde(rename_all = "snake_case")]
1501-
pub struct UpdateEliminationBucketEventResponse {
1502-
pub status: EliminationUpdationStatusEventResponse,
1503-
}
1504-
1505-
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1506-
#[serde(rename_all = "snake_case")]
1507-
pub enum EliminationUpdationStatusEventResponse {
1508-
BucketUpdationSucceeded,
1509-
BucketUpdationFailed,
1510-
}
1511-
1512-
#[derive(Clone, Debug, Serialize, Deserialize)]
1513-
#[serde(rename_all = "snake_case")]
1514-
pub struct ContractLabelInformationEventRequest {
1515-
pub label: String,
1516-
pub target_count: u64,
1517-
pub target_time: u64,
1518-
pub current_count: u64,
1519-
}
1520-
1521-
#[derive(Clone, Debug, Serialize, Deserialize)]
1522-
#[serde(rename_all = "snake_case")]
1523-
pub struct UpdateContractRequestEventRequest {
1524-
pub id: String,
1525-
pub params: String,
1526-
pub labels_information: Vec<ContractLabelInformationEventRequest>,
1527-
}
1528-
1529-
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1530-
#[serde(rename_all = "snake_case")]
1531-
pub struct UpdateContractEventResponse {
1532-
pub status: ContractUpdationStatusEventResponse,
1533-
}
1534-
1535-
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
1536-
#[serde(rename_all = "snake_case")]
1537-
pub enum ContractUpdationStatusEventResponse {
1538-
ContractUpdationSucceeded,
1539-
ContractUpdationFailed,
1540-
}
15411387
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
15421388
pub struct RuleMigrationQuery {
15431389
pub profile_id: common_utils::id_type::ProfileId,

crates/router/src/core/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ pub enum RoutingError {
388388
DecisionEngineValidationError(String),
389389
#[error("Invalid transaction type")]
390390
InvalidTransactionType,
391+
#[error("Routing events error: {message}, status code: {status_code}")]
392+
RoutingEventsError { message: String, status_code: u16 },
391393
}
392394

393395
#[derive(Debug, Clone, thiserror::Error)]

0 commit comments

Comments
 (0)