Skip to content

Conversation

@prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Jan 7, 2026

Type of Change

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

Description

This pull request refactors the routing logic in the payments core to introduce a new extensible routing pipeline using the RoutingStage trait and associated stage structs. The changes modularize static and dynamic routing logic, encapsulate routing results, and simplify dynamic routing integration with Open Router. This makes the routing process more maintainable and extensible for future enhancements.

Routing Pipeline Refactor and Abstractions:

  • Introduced a new RoutingStage async trait and implemented it for StaticRoutingStage and (conditionally) DynamicRoutingStage, allowing routing logic to be composed as a pipeline of stages. The apply method encapsulates each stage's logic and takes/returns a new RoutingOutcome struct.
  • Added the RoutingOutcome struct to carry connectors and routing approach through the pipeline, replacing ad-hoc tuple passing.

Core Routing Logic Changes:

  • Refactored the main routing function in payments.rs to use the new pipeline: first applying the static routing stage, then (if enabled) the dynamic routing stage, updating the payment data with the final routing approach.
  • Updated connector data extraction to use the new RoutingOutcome struct.

Dynamic Routing Integration:

  • Refactored dynamic routing with Open Router to return a new DynamicRoutingResult struct, encapsulating connectors and routing approach, and updated all call sites to use this new result type. [1] [2] [3] [4] [5] [6] [7]

Dependency and Import Updates:

  • Added necessary imports for the new trait and struct usage, such as RoutingStage.

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?

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

@prajjwalkumar17 prajjwalkumar17 requested review from a team as code owners January 7, 2026 12:31
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jan 7, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments.rs  16% smaller
  crates/router/src/core/payments/routing.rs  6% smaller
  crates/router/src/core/routing.rs  0% smaller

@prajjwalkumar17 prajjwalkumar17 self-assigned this Jan 7, 2026
@prajjwalkumar17 prajjwalkumar17 marked this pull request as draft January 7, 2026 12:31
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 21.21212% with 26 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@46bb969). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/router/src/core/payments/routing.rs 0.00% 26 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10854   +/-   ##
=======================================
  Coverage        ?    6.33%           
=======================================
  Files           ?     1273           
  Lines           ?   322269           
  Branches        ?        0           
=======================================
  Hits            ?    20400           
  Misses          ?   301869           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@prajjwalkumar17 prajjwalkumar17 added the A-euclid-foc Area: Euclid Family of Crates label Jan 7, 2026
@prajjwalkumar17 prajjwalkumar17 linked an issue Jan 7, 2026 that may be closed by this pull request
@prajjwalkumar17 prajjwalkumar17 marked this pull request as ready for review January 7, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-euclid-foc Area: Euclid Family of Crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(routing): de-couple dynamic and static routing

3 participants