Skip to content
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

Add retry mechanism to CompoundRateProvider.getExchangeRate on failure #419

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sernamar
Copy link
Contributor

@sernamar sernamar commented Sep 1, 2024

This PR introduces a retry mechanism to CompoundRateProvider.getExchangeRate by adding an overloaded version with a failFast parameter:

  • if failFast is set to true, the method retains its original behavior, throwing an exception immediately on the first provider failure.
  • if failFast is set to false, the method logs a warning and continues attempting to retrieve an exchange rate from the next provider.

This way users can choose whether to fail immediately or attempt to use other providers if one fails. The default behavior remains unchanged (i.e., fails immediately), ensuring backward compatibility.

This change addresses issue #385 and provides more flexibility in handling provider failures.


This change is Reviewable

Modified the getExchangeRate method in the CompoundRateProvider class to introduce a failFast parameter.

Previously, the method would immediately throw an exception on the first provider failure. This change allows for a more flexible approach by adding an option to continue attempting to get an exchange rate from subsequent providers if failFast is set to false.

- Added a new overloaded getExchangeRate method with a failFast boolean parameter.
- If failFast is true, the method retains the original behavior of failing immediately on the first exception.
- If failFast is false, the method logs a warning and continues to the next provider in case of an exception.

This update addresses some of the limitations described in issue JavaMoney#385.
@sernamar sernamar changed the title Issue 385 Add retry mechanism to CompoundRateProvider.getExchangeRate on failure Sep 1, 2024
@sernamar sernamar marked this pull request as ready for review September 2, 2024 04:34
@keilw keilw self-requested a review October 23, 2024 12:21
@keilw keilw added this to the 1.4.5 milestone Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants