We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
hello.
I ran into this issue when retry attempts == 1...the failAction is not being triggered and then i reviewed the code:
def retry[T](maxRetries: Option[Int], interval: Duration = DefaultInterval, backoff: Backoff = exponentialBackoff, failAction: Throwable => Unit = doNothing) (f: => Try[T]): Try[T] = { @tailrec def loop(retry: Int): Try[T] = f match { case s @ Success(_) => s case Failure(e) if maxRetries.forall(_ > retry) => failAction(e) sleep(backoff(retry, interval)) loop(retry + 1) case fail => fail } loop(1) }
i think the failAction should always trigger for a Failure even if maxRetries == 1. it should read like:
failAction
Failure
maxRetries == 1
def retry[T](maxRetries: Option[Int], interval: Duration = DefaultInterval, backoff: Backoff = exponentialBackoff, failAction: Throwable => Unit = doNothing) (f: => Try[T]): Try[T] = { @tailrec def loop(retry: Int): Try[T] = f match { case s @ Success(_) => s case Failure(e) => failAction(e) // call the callback if maxRetries.forall(_ > retry) { sleep(backoff(retry, interval)) loop(retry + 1) } case fail => fail } loop(1) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
hello.
I ran into this issue when retry attempts == 1...the failAction is not being triggered and then i reviewed the code:
i think the
failAction
should always trigger for aFailure
even ifmaxRetries == 1
. it should read like:The text was updated successfully, but these errors were encountered: