refactor(open_router): call elimination routing of open router if enabled instead of dynamo #7961
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
This pull request introduces significant updates to the dynamic routing logic, focusing on enhancing the success-based routing mechanism and improving the integration with the "open router" service. Key changes include the addition of a new helper method, refactoring of existing methods for better clarity, and updates to the routing logic to streamline decision-making.
Enhancements to Dynamic Routing Logic:
is_success_rate_routing_enabled
inDynamicRoutingAlgorithmRef
to determine if success-based routing is enabled, improving readability and encapsulation. (crates/api_models/src/routing.rs
)perform_open_routing
function to consolidate success-based and elimination routing into a single API call, simplifying the logic for deciding gateways. (crates/router/src/core/payments/routing.rs
) [1] [2]Integration with Open Router:
update_gateway_score_helper_with_open_router
to handle gateway score updates when routing through the open router. This replaces the previouspush_metrics_with_update_window_for_success_based_routing
in relevant contexts. (crates/router/src/core/routing/helpers.rs
) [1] [2]update_success_rate_score_with_open_router
toupdate_gateway_score_with_open_router
andperform_success_based_routing_with_open_router
toperform_decide_gateway_call_with_open_router
for better alignment with their functionality. (crates/router/src/core/payments/routing.rs
) [1] [2] [3]Refactor and Cleanup:
payment_response_update_tracker
function to include conditional logic for routing decisions based on the open router's configuration, ensuring better error handling and logging. (crates/router/src/core/payments/operations/payment_response.rs
) [1] [2]push_metrics_with_update_window_for_success_based_routing
function with a more focused implementation, while retaining the original logic for backward compatibility. (crates/router/src/core/routing/helpers.rs
)These changes collectively improve the maintainability, readability, and functionality of the dynamic routing system, particularly in scenarios involving success-based routing and open router integration.
Additional Changes
Motivation and Context
How did you test it?
Since the feature cannot be deployed in main pod, this can be tested through custom pod which I can help with
Checklist
cargo +nightly fmt --all
cargo clippy