Package io.servicetalk.client.api
Class AbstractRetryingFilterBuilder<Builder extends AbstractRetryingFilterBuilder<Builder,Filter,Meta>,Filter,Meta>
- java.lang.Object
-
- io.servicetalk.client.api.AbstractRetryingFilterBuilder<Builder,Filter,Meta>
-
- Type Parameters:
Builder
- the type of builder for retrying filterFilter
- the type of retrying filter to buildMeta
- the type of meta-data forretryFor(BiPredicate)
- Direct Known Subclasses:
RetryingHttpRequesterFilter.Builder
public abstract class AbstractRetryingFilterBuilder<Builder extends AbstractRetryingFilterBuilder<Builder,Filter,Meta>,Filter,Meta> extends java.lang.Object
An abstract builder for retrying filters.- See Also:
RetryStrategies
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractRetryingFilterBuilder.ReadOnlyRetryableSettings<Meta>
A read-only settings for retryable filters.
-
Constructor Summary
Constructors Constructor Description AbstractRetryingFilterBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Filter
build(AbstractRetryingFilterBuilder.ReadOnlyRetryableSettings<Meta> readOnlySettings)
Builds a retryingAbstractRetryingFilterBuilder
for providedReadOnlyRetryableSettings<Meta>
.Filter
buildWithConstantBackoff(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds the passed constantDuration
as a delay between retries.Filter
buildWithConstantBackoff(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds the passed constantDuration
as a delay between retries.Filter
buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.Filter
buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.Filter
buildWithConstantBackoffFullJitter(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.Filter
buildWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.Filter
buildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries.Filter
buildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries.Filter
buildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries.Filter
buildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries.Filter
buildWithImmediateRetries()
Creates a new retryingAbstractRetryingFilterBuilder
which retries without delay.java.util.function.BiPredicate<Meta,java.lang.Throwable>
defaultRetryForPredicate()
Returns a default value forretryFor(BiPredicate)
.Builder
maxRetries(int maxRetries)
Set the maximum number of allowed retry operations before giving up.Builder
retryFor(java.util.function.BiPredicate<Meta,java.lang.Throwable> retryForPredicate)
Overrides the default criterion for determining which requests or errors should be retried.
-
-
-
Method Detail
-
maxRetries
public final Builder maxRetries(int maxRetries)
Set the maximum number of allowed retry operations before giving up.- Parameters:
maxRetries
- Maximum number of allowed retries before giving up- Returns:
this
-
retryFor
public final Builder retryFor(java.util.function.BiPredicate<Meta,java.lang.Throwable> retryForPredicate)
Overrides the default criterion for determining which requests or errors should be retried.- Parameters:
retryForPredicate
-BiPredicate
that checks whether a given combination ofmeta-data
andcause
should be retried- Returns:
this
-
buildWithImmediateRetries
public final Filter buildWithImmediateRetries()
Creates a new retryingAbstractRetryingFilterBuilder
which retries without delay.- Returns:
- a new retrying
AbstractRetryingFilterBuilder
which retries without delay
-
buildWithConstantBackoff
public final Filter buildWithConstantBackoff(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds the passed constantDuration
as a delay between retries.- Parameters:
delay
- ConstantDuration
of delay between retries- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a constant delay between retries
-
buildWithConstantBackoff
public final Filter buildWithConstantBackoff(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds the passed constantDuration
as a delay between retries.- Parameters:
delay
- ConstantDuration
of delay between retriestimerExecutor
-Executor
to be used to schedule timers for backoff. It takes precedence over an alternative timerExecutor
fromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)
argument- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a constant delay between retries
-
buildWithConstantBackoffFullJitter
public final Filter buildWithConstantBackoffFullJitter(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
delay
- MaximumDuration
of delay between retries- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a randomized delay between retries
-
buildWithConstantBackoffFullJitter
public final Filter buildWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
delay
- MaximumDuration
of delay between retriestimerExecutor
-Executor
to be used to schedule timers for backoff. It takes precedence over an alternative timerExecutor
fromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)
argument- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a randomized delay between retries
-
buildWithConstantBackoffDeltaJitter
public final Filter buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.- Parameters:
delay
- MaximumDuration
of delay between retriesjitter
- The jitter which is used as and offset toinitialDelay
on each retry- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a randomized delay between retries
-
buildWithConstantBackoffDeltaJitter
public final Filter buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a randomized delay between retries and uses the passedDuration
as a maximum delay possible.- Parameters:
delay
- MaximumDuration
of delay between retriesjitter
- The jitter which is used as and offset todelay
on each retrytimerExecutor
-Executor
to be used to schedule timers for backoff. It takes precedence over an alternative timerExecutor
fromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)
argument- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds a randomized delay between retries
-
buildWithExponentialBackoffFullJitter
public final Filter buildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay
- DelayDuration
for the first retry and increased exponentially with each retrymaxDelay
- The maximum amount of delay that will be introduced.- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds an exponentially increasing delay between retries with jitter
-
buildWithExponentialBackoffFullJitter
public final Filter buildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay
- DelayDuration
for the first retry and increased exponentially with each retrymaxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff. It takes precedence over an alternative timerExecutor
fromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)
argument- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds an exponentially increasing delay between retries with jitter
-
buildWithExponentialBackoffDeltaJitter
public final Filter buildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries.- Parameters:
initialDelay
- DelayDuration
for the first retry and increased exponentially with each retryjitter
- The jitter which is used as and offset toinitialDelay
on each retrymaxDelay
- The maximum amount of delay that will be introduced.- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds an exponentially increasing delay between retries with jitter
-
buildWithExponentialBackoffDeltaJitter
public final Filter buildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilder
which adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries.- Parameters:
initialDelay
- DelayDuration
for the first retry and increased exponentially with each retryjitter
- The jitter which is used as and offset toinitialDelay
on each retrymaxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff. It takes precedence over an alternative timerExecutor
fromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)
argument- Returns:
- A new retrying
AbstractRetryingFilterBuilder
which adds an exponentially increasing delay between retries with jitter
-
build
protected abstract Filter build(AbstractRetryingFilterBuilder.ReadOnlyRetryableSettings<Meta> readOnlySettings)
Builds a retryingAbstractRetryingFilterBuilder
for providedReadOnlyRetryableSettings<Meta>
.- Parameters:
readOnlySettings
- a read-only settings for retryable filters- Returns:
- A new retrying
AbstractRetryingFilterBuilder
-
defaultRetryForPredicate
public java.util.function.BiPredicate<Meta,java.lang.Throwable> defaultRetryForPredicate()
Returns a default value forretryFor(BiPredicate)
.- Returns:
- a default value for
retryFor(BiPredicate)
-
-