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

More examples in docs #51

Open
cb372 opened this issue Jun 23, 2019 · 3 comments
Open

More examples in docs #51

cb372 opened this issue Jun 23, 2019 · 3 comments

Comments

@cb372
Copy link
Owner

cb372 commented Jun 23, 2019

There are a couple of "TODO example" on the Combinators page that need to be filled in.

I think a section on the Retry Policies page that maps from a few use cases to Scala code could also be useful, e.g.

  • how to retry 5 times, waiting 100 milliseconds between attempts
  • how to do exponential backoff but cap the delay between intervals at 1 second
  • how to do Fibonacci backoff but give up if the total delay exceeds 5 seconds
@LukaJCB
Copy link
Collaborator

LukaJCB commented Jun 24, 2019

Agreed! I was going to do another PR soon with docs for mapDelay and mapK, I can pick these up too, if no one else wants to :)

@cb372
Copy link
Owner Author

cb372 commented Jul 1, 2019

An example of followedBy would be good too, e.g. retry 3 times and then switch to exponential backoff

@kxa14
Copy link

kxa14 commented May 19, 2021

Hi @cb372 ,

There is a slight mistake in the documentation. https://cb372.github.io/cats-retry/docs/combinators.html

In the example of retryingOnFailuresAndAllErrors, the policy and wasSuccessful positional arguments are in the wrong order. Just swipe them around would do.

Original:

val io = retryingOnFailuresAndAllErrors(
  wasSuccessful = (s: String) => IO.pure(s != "pending"),
  policy = RetryPolicies.limitRetries[IO](5),
  onFailure = retry.noop[IO, String],
  onError = retry.noop[IO, Throwable]
)(flakyRequest)

Corrected:

val io = retryingOnFailuresAndAllErrors(
 policy = RetryPolicies.limitRetries[IO](5),
  wasSuccessful = (s: String) => IO.pure(s != "pending"),
  onFailure = retry.noop[IO, String],
  onError = retry.noop[IO, Throwable]
)(flakyRequest)

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

No branches or pull requests

3 participants