trait Retry extends LazyLogger
- Alphabetic
- By Inheritance
- Retry
- LazyLogger
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
def
directly[F[_], A](maxRetries: Int = 5)(ioa: F[A])(implicit F: ApplicativeError[F, Throwable]): F[A]
If your IO carries an error, retry.
If your IO carries an error, retry. If you want to have retry based a bad status, ensure your IO has converted the desired statuses to an effect failure first (see
ensureSeccussfulStatus
). -
def
getMessage(t: Throwable, fallback: String = "no message"): String
Extract a message from
t
via "getMessage" or the underlying "cause" exception.Extract a message from
t
via "getMessage" or the underlying "cause" exception. Use fallback if neither of those found. -
lazy val
logger: Logger
- Definition Classes
- LazyLogger
-
def
makeSomeStatusesErrors[F[_]](isError: (Status) ⇒ Boolean = shouldRetry)(implicit F: ApplicativeError[F, Throwable]): Kleisli[F, DisposableResponse[F], DisposableResponse[F]]
Convert an effect containing a
DisposableResponse
, if it fails predictate, to an F UnexpectedStatus error.Convert an effect containing a
DisposableResponse
, if it fails predictate, to an F UnexpectedStatus error. Otherwise leave it untouched. Success is defined by the predicate. If you have aKleisli[F,?,DisposableResponse]
you can obtain aKleisli[F,?,DisposableResponse]
usingk1 andThen k2
and ensure your effect carries a failure if the status does not satisfypredicate
. Callers can use this function if they are not sure that an effect carrying aDisposableResponse
has converted the effect to contain an error for specific status codes. -
def
retryIfRetryableThrowables[F[_], A](policy: (F[A]) ⇒ F[A], isRetryableStatus: (Status) ⇒ Boolean = shouldRetry)(implicit F: ApplicativeError[F, Throwable]): (F[A]) ⇒ F[A]
Create a retry policy that retries on
CommunicationFailure
,DecodeFailure
or UnexpectedStatus (if isRetryableStatus(status) is true) failures.Create a retry policy that retries on
CommunicationFailure
,DecodeFailure
or UnexpectedStatus (if isRetryableStatus(status) is true) failures.- policy
The retry policy called if failure is detected.
-
def
shouldRetry(s: Status): Boolean
Return true if the status *suggests* that the request should be retried.
Return true if the status *suggests* that the request should be retried. The statuses include: InternalServerError, ServiceUnavailable, BadGateway, GatewayTimeout, TooManyRequests which is a good starting point for dynamics.
-
def
withBackoff[F[_], A](initialDelay: FiniteDuration = 5.seconds, maxRetries: Int = 5)(ioa: F[A])(implicit F: ApplicativeError[F, Throwable], timer: Timer[F]): F[A]
If your F carries an error, retry.
If your F carries an error, retry. If you want to have retry based a bad status, ensure your IO has converted the desired statuses to an effect failure first (see
ensureSeccussfulStatus
). -
def
withPause[F[_], A](delayBetween: FiniteDuration = 5.seconds, maxRetries: Int = 5)(ioa: F[A])(implicit F: ApplicativeError[F, Throwable], timer: Timer[F]): F[A]
If your IO carries an error, retry.
If your IO carries an error, retry. If you want to have retry based a bad status, ensure your IO has converted the desired statuses to an effect failure first (see
ensureSeccussfulStatus
).