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

feat(client): add support for global retry configuration #380

Merged
merged 2 commits into from
May 6, 2022

Conversation

pablopalacios
Copy link
Contributor

@redonkulus we were only able to set retry configuration per request. Now, it's possible to set some (or all) configuration globally:

const fetchr = new Fetchr({
    retry: {
     interval: 350,
     statusCodes: [0, 502, 504],
   },
});

fetchr.read('resource').clientConfig({ retry: { maxRetries: 2 } }).end();

This avoids repeating some configuration that (at least in our case) are always the same.

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@pablopalacios
Copy link
Contributor Author

Soooo, @redonkulus , would it be possible to check this one?

Copy link
Contributor

@redonkulus redonkulus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m fine with a global config. Added one comment. We should document this in the readme too.

statsCollector: options.statsCollector,
unsafeAllowRetry: Boolean(options.unsafeAllowRetry),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is called unsafe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unsafeAllowRetry allows POST requests to be retried. In many cases, however, one would not like to have this feature enabled (since it could lead to duplicated transactions in the back-end). For me, a better name would be retryOnPost or something like this so it's clear what is happening (or, perhaps, removing this flag completely since, right now, retry is disabled by default).

Regarding the documentation, it's already in the readme:

**Note:** Fetchr doesn't retry POST requests for safety reasons. You can enable retries for POST requests by setting the `unsafeAllowRetry` property to `true`:

@konarkmodi
Copy link

@redonkulus @pablopalacios : Thanks to both of you for keeping this project alive and kicking. It's total bliss to use it.
Would it be possible to move this PR ahead and make the retry options globally available?

@redonkulus
Copy link
Contributor

@konarkmodi thanks for the kind words. @pablopalacios do you want to update the readme, then we can get this merged?

@pablopalacios
Copy link
Contributor Author

@redonkulus I thought it was already there. In any case, I updated the documentation to make it clearer (hopefully :D).

Copy link
Contributor

@redonkulus redonkulus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the docs update, its clearer now.

@redonkulus redonkulus merged commit cd21c04 into yahoo:master May 6, 2022
@redonkulus
Copy link
Contributor

https://github.com/yahoo/fetchr/releases/tag/v0.7.9

@pablopalacios pablopalacios deleted the add-global-retry branch July 23, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants