Skip to content

refactor(euclid): refactor logs for evaluation of equality for dynamic routing evaluate response #8834

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

Merged
merged 7 commits into from
Aug 8, 2025

Conversation

prajjwalkumar17
Copy link
Member

@prajjwalkumar17 prajjwalkumar17 commented Aug 4, 2025

Type of Change

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

Description

This PR refactors the routing logic to improve how logs are emitted and connector evaluation is handled when dynamic routing is performed using the Decision Engine (Euclid). Key updates include:

  • Replaces raw response propagation from perform_decision_euclid_routing with a wrapped RoutingEvaluateResponse containing both output and evaluated_output.
  • Introduces a new function extract_de_output_connectors() to deserialize and normalize output from Euclid into a list of ConnectorInfo.
  • Adds transform_de_output_for_router() to combine output and evaluated_output, ensuring deduplication and priority order.
  • Enhances logging in compare_and_log_result to include diff details between de_result and router_result more clearly.
  • Adds TryFrom<ConnectorInfo> for DeRoutableConnectorChoice to safely convert API inputs to internal representations.

Diff Hunk Explanation

crates/router/src/core/payments/routing.rs

  • Renamed de_euclid_connectorsde_evaluated_connector to reflect the structured response.
  • Wrapped perform_decision_euclid_routing call with success match block to:
    • Extract connectors from output using extract_de_output_connectors.
    • Merge output and evaluated_output using transform_de_output_for_router.
  • Updated logs to emit clearer error/debug statements during extraction, transformation, and comparison.

crates/router/src/core/payments/routing/utils.rs

  • Refactored perform_decision_euclid_routing to return RoutingEvaluateResponse instead of just connector list.
  • Added extract_de_output_connectors: deserializes various output types (single, priority, volume_split, etc.).
  • Added transform_de_output_for_router: deduplicates connectors and maintains priority between evaluated_output and fallback output.
  • Improved compare_and_log_result to log equality and diff details between Decision Engine result and final connector result.
  • Introduced TryFrom<ConnectorInfo> for DeRoutableConnectorChoice.

This refactor sets the stage for cleaner observability and deterministic routing behavior between evaluated and fallback paths.

How did you test it?

The testing guidelines are present in this doc.

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 August 4, 2025 12:02
Copy link

semanticdiff-com bot commented Aug 4, 2025

Review changes with  SemanticDiff

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

@prajjwalkumar17 prajjwalkumar17 marked this pull request as draft August 4, 2025 12:02
@prajjwalkumar17 prajjwalkumar17 self-assigned this Aug 4, 2025
@prajjwalkumar17 prajjwalkumar17 marked this pull request as ready for review August 5, 2025 10:39
@prajjwalkumar17 prajjwalkumar17 added the A-euclid-foc Area: Euclid Family of Crates label Aug 5, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Aug 8, 2025
Merged via the queue into main with commit ef27ac5 Aug 8, 2025
22 of 26 checks passed
@likhinbopanna likhinbopanna deleted the refactor_routing_logs branch August 8, 2025 13:23
pixincreate added a commit that referenced this pull request Aug 8, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch:
  feat(core): Adding integration for webhooks through UCS (#8814)
  refactor(euclid): refactor logs for evaluation of equality for dynamic routing evaluate response (#8834)
  feat(connector): [SIFT] add Connector Template Code  (#8488)
  feat(router): Add tokenization support for proxy and update the route for proxy (#8530)
  fix(ci): Fix Spell Check For CI Pull Request (#8857)
  feat(checkbook_io): connector integrate ACH (#8730)
  fix(connector): Change Refund Reason Type in Adyen (#8849)
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(euclid): refactor logs for evaluation of equality for dynamic routing evaluate response
5 participants