Package-level declarations

Types

Link copied to clipboard

Implements a retry strategy with exponential backoff, a token bucket for limiting retries, and a client-side rate limiter for achieving the ideal request rate. Note that the backoff delayer, token bucket, and rate limiter all work independently of each other. Any of the three may delay retries (and the rate limiter may delay the initial try as well).

Link copied to clipboard
sealed class Outcome<out T>

Represents the outcome of a repeated operation. This type is similar to a Result except it is a union type and has no flag for "success" since exceptional outcomes do not necessarily represent "failure".

Link copied to clipboard

Indicates some failure happened while retrying.

Link copied to clipboard
class RetryFailureException(message: String, cause: Throwable?, val attempts: Int, val lastResponse: Any?) : RetryException

Indicates the retrying has failed because of a non-retryable condition.

Link copied to clipboard
interface RetryStrategy

A strategy for trying a block of code one or more times.

Link copied to clipboard
Link copied to clipboard
open class StandardRetryStrategy(val config: StandardRetryStrategy.Config = Config.default()) : RetryStrategy

Implements a retry strategy utilizing backoff delayer and a token bucket for rate limiting and circuit breaking. Note that the backoff delayer and token bucket work independently of each other. Either can delay retries (and the token bucket can delay the initial try). The delayer is called first so that the token bucket can refill as appropriate.

Link copied to clipboard
class TimedOutException(message: String, val attempts: Int, val lastResponse: Any?, val lastException: Throwable?) : RetryException

Indicates that retrying has failed because too much time has elapsed.

Link copied to clipboard
class TooManyAttemptsException(message: String, cause: Throwable?, val attempts: Int, val lastResponse: Any?, val lastException: Throwable?) : RetryException

Indicates that retrying has failed because too many attempts have completed unsuccessfully.

Inherited functions

Link copied to clipboard
fun <T> Outcome<T>.getOrThrow(): T

Gets the non-exceptional response in this outcome if it exists. Otherwise, throws the exception in this outcome.

Link copied to clipboard
fun <T> Outcome<T>.toResult(): <Error class: unknown class><T>

Convert an outcome to a Result