-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(routing): Integrate global success rates #6950
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
@@ -809,6 +811,13 @@ pub struct CurrentBlockThreshold { | |||
pub max_total_count: Option<u64>, | |||
} | |||
|
|||
#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)] | |||
pub enum SuccessRateSpecificityLevel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this type has to be mentioned in openapi.rs files?
if let Some(level) = new.specificity_level { | ||
self.specificity_level = Some(level) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
if let Some(level) = new.specificity_level { | |
self.specificity_level = Some(level) | |
} | |
self.specificity_level = new.specificity_level; |
@@ -49,6 +52,15 @@ pub trait SuccessBasedDynamicRouting: dyn_clone::DynClone + Send + Sync { | |||
id: String, | |||
headers: GrpcHeaders, | |||
) -> DynamicRoutingResult<InvalidateWindowsResponse>; | |||
/// To calculate both global and merchant specific success rate for the list of chosen connectors | |||
async fn calculate_global_success_rate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include merchant too here in method name
.fetch_entity_and_global_success_rate(request) | ||
.await | ||
.change_context(DynamicRoutingError::SuccessRateBasedRoutingFailure( | ||
"Failed to fetch the success rate".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Failed to fetch the success rate".to_string(), | |
"Failed to fetch the entity and global success rate".to_string(), |
.first() | ||
.ok_or(errors::ApiErrorResponse::InternalServerError) | ||
.attach_printable( | ||
"unable to fetch the first connector from list of connectors obtained from dynamic routing service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unable to fetch the first connector from list of connectors obtained from dynamic routing service", | |
"unable to fetch the first connector from list of global connectors obtained from dynamic routing service", |
))?; | ||
|
||
let outcome = get_success_based_metrics_outcome_for_payment( | ||
payment_status_attribute, | ||
payment_connector.to_string(), | ||
first_success_based_connector.to_string(), | ||
first_merchant_success_based_connector.to_string(), | ||
); | ||
|
||
let dynamic_routing_stats = DynamicRoutingStatsNew { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we create a new column here which stores the globally_top_performing_connector
at the time this particular payment was made?
cc: @prajjwalkumar17
there's conflicts too. please add test cases as well |
#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)] | ||
pub enum SuccessRateSpecificityLevel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)] | |
pub enum SuccessRateSpecificityLevel { | |
#[derive(serde::Serialize, serde::Deserialize, Debug, Default, Clone, ToSchema)] | |
#[serde(rename_all = "snake_case")] | |
pub enum SuccessRateSpecificityLevel { |
@@ -801,6 +802,7 @@ pub struct SuccessBasedRoutingConfigBody { | |||
pub default_success_rate: Option<f64>, | |||
pub max_aggregates_size: Option<u32>, | |||
pub current_block_threshold: Option<CurrentBlockThreshold>, | |||
pub specificity_level: Option<SuccessRateSpecificityLevel>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making this optional and manually filling this field for the old entries, we can make this a required field but derive a #[serde(default)]
attribute on top so that when getting deserialised, serde will take care of setting this to a default value instead of you doing it. this shouldn't cause any backwards compatibility issues. what do you think?
pub specificity_level: Option<SuccessRateSpecificityLevel>, | |
#[serde(default)] | |
pub specificity_level: SuccessRateSpecificityLevel, |
success_based_routing_configs.config.as_mut().map(|config| { | ||
config.specificity_level = | ||
Some(api_models::routing::SuccessRateSpecificityLevel::Merchant) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this now because serde will take care of it
Type of Change
Description
Integrate global Success rates for dynamic routing
Additional Changes
Motivation and Context
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy