Skip to content

Conversation

Chethan-rao
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

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:

  • Added a new method is_success_rate_routing_enabled in DynamicRoutingAlgorithmRef to determine if success-based routing is enabled, improving readability and encapsulation. (crates/api_models/src/routing.rs)
  • Modified the 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:

  • Introduced a new helper function update_gateway_score_helper_with_open_router to handle gateway score updates when routing through the open router. This replaces the previous push_metrics_with_update_window_for_success_based_routing in relevant contexts. (crates/router/src/core/routing/helpers.rs) [1] [2]
  • Renamed methods like update_success_rate_score_with_open_router to update_gateway_score_with_open_router and perform_success_based_routing_with_open_router to perform_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:

  • Refactored the 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]
  • Reintroduced the 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

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

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

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Chethan-rao Chethan-rao added C-refactor Category: Refactor A-routing Area: Routing labels May 5, 2025
@Chethan-rao Chethan-rao self-assigned this May 5, 2025
@Chethan-rao Chethan-rao requested review from a team as code owners May 5, 2025 12:20
Copy link

semanticdiff-com bot commented May 5, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/routing.rs  82% smaller
  crates/router/src/core/payments/operations/payment_response.rs  82% smaller
  crates/router/src/core/routing/helpers.rs  45% smaller
  crates/router/src/core/payments.rs  31% smaller
  crates/router/src/core/errors.rs  4% smaller
  crates/api_models/src/routing.rs  0% smaller

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 12, 2025
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue May 12, 2025
Merged via the queue into main with commit bab64ee May 12, 2025
16 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the handle-dynamo-vs-or branch May 12, 2025 14:19
pixincreate added a commit that referenced this pull request May 12, 2025
…adyen-ideal

* 'main' of github.com:juspay/hyperswitch: (62 commits)
  fix(core): language consumption from locale in payment and payout links (#7993)
  feat(refunds_v2): Add refunds list flow in v2 apis (#7966)
  refactor(connector): [Noon] auth header (#7977)
  fix(connector): [Novalnet] send decoded token for apple pay payment (#7973)
  feat(business_profile): add business_profile config to enable external vault (#7876)
  feat(vsaas): integrate onboarding flow for vertical saas (#7884)
  feat(connector): Introduce connector template code for WorldpayXML  (#7968)
  feat(connector): [ADYEN, CHECKOUT] Added In Feature Matrix API (#7914)
  feat(core): add psync support for recovery external payments (#7855)
  refactor(open_router): call elimination routing of open router if enabled instead of dynamo (#7961)
  feat(payment_methods): add v2 api for fetching token data (#7629)
  ci(cypress): Fix Bank Redirects for stripe test (#8004)
  chore(version): 2025.05.12.0
  refactor(authentication): moved cavv storing from table to temp locker (#7978)
  chore(version): 2025.05.09.0
  feat(connector): [paypal, trustpay] add in feature matrix (#7911)
  fix(update_metadata): Update Metadata for any connectors other than stripe gives 500 error (#7984)
  fix(router): Fixed stack over flow for session call in authentication connectors (#7983)
  chore(version): 2025.05.08.0
  fix(payment): disable payment update via client config (#7970)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor(open_router): call elimination routing of open router if enabled instead of dynamo
4 participants