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.ObjectAn abstract builder for retrying filters.- See Also:
RetryStrategies
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractRetryingFilterBuilder.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 Filterbuild(AbstractRetryingFilterBuilder.ReadOnlyRetryableSettings<Meta> readOnlySettings)Builds a retryingAbstractRetryingFilterBuilderfor providedReadOnlyRetryableSettings<Meta>.FilterbuildWithConstantBackoff(java.time.Duration delay)Creates a new retryingAbstractRetryingFilterBuilderwhich adds the passed constantDurationas a delay between retries.FilterbuildWithConstantBackoff(java.time.Duration delay, Executor timerExecutor)Creates a new retryingAbstractRetryingFilterBuilderwhich adds the passed constantDurationas a delay between retries.FilterbuildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.FilterbuildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.FilterbuildWithConstantBackoffFullJitter(java.time.Duration delay)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.FilterbuildWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.FilterbuildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a delay between retries.FilterbuildWithExponentialBackoffDeltaJitter(java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a delay between retries.FilterbuildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a delay between retries.FilterbuildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retryingAbstractRetryingFilterBuilderwhich adds a delay between retries.FilterbuildWithImmediateRetries()Creates a new retryingAbstractRetryingFilterBuilderwhich retries without delay.java.util.function.BiPredicate<Meta,java.lang.Throwable>defaultRetryForPredicate()Returns a default value forretryFor(BiPredicate).BuildermaxRetries(int maxRetries)Set the maximum number of allowed retry operations before giving up.BuilderretryFor(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-BiPredicatethat checks whether a given combination ofmeta-dataandcauseshould be retried- Returns:
this
-
buildWithImmediateRetries
public final Filter buildWithImmediateRetries()
Creates a new retryingAbstractRetryingFilterBuilderwhich retries without delay.- Returns:
- a new retrying
AbstractRetryingFilterBuilderwhich retries without delay
-
buildWithConstantBackoff
public final Filter buildWithConstantBackoff(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds the passed constantDurationas a delay between retries.- Parameters:
delay- ConstantDurationof delay between retries- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a constant delay between retries
-
buildWithConstantBackoff
public final Filter buildWithConstantBackoff(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds the passed constantDurationas a delay between retries.- Parameters:
delay- ConstantDurationof delay between retriestimerExecutor-Executorto be used to schedule timers for backoff. It takes precedence over an alternative timerExecutorfromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)argument- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a constant delay between retries
-
buildWithConstantBackoffFullJitter
public final Filter buildWithConstantBackoffFullJitter(java.time.Duration delay)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
delay- MaximumDurationof delay between retries- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a randomized delay between retries
-
buildWithConstantBackoffFullJitter
public final Filter buildWithConstantBackoffFullJitter(java.time.Duration delay, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
delay- MaximumDurationof delay between retriestimerExecutor-Executorto be used to schedule timers for backoff. It takes precedence over an alternative timerExecutorfromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)argument- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a randomized delay between retries
-
buildWithConstantBackoffDeltaJitter
public final Filter buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.- Parameters:
delay- MaximumDurationof delay between retriesjitter- The jitter which is used as and offset toinitialDelayon each retry- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a randomized delay between retries
-
buildWithConstantBackoffDeltaJitter
public final Filter buildWithConstantBackoffDeltaJitter(java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds a randomized delay between retries and uses the passedDurationas a maximum delay possible.- Parameters:
delay- MaximumDurationof delay between retriesjitter- The jitter which is used as and offset todelayon each retrytimerExecutor-Executorto be used to schedule timers for backoff. It takes precedence over an alternative timerExecutorfromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)argument- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds a randomized delay between retries
-
buildWithExponentialBackoffFullJitter
public final Filter buildWithExponentialBackoffFullJitter(java.time.Duration initialDelay, java.time.Duration maxDelay)
Creates a new retryingAbstractRetryingFilterBuilderwhich adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay- DelayDurationfor the first retry and increased exponentially with each retrymaxDelay- The maximum amount of delay that will be introduced.- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich 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 retryingAbstractRetryingFilterBuilderwhich adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
initialDelay- DelayDurationfor the first retry and increased exponentially with each retrymaxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff. It takes precedence over an alternative timerExecutorfromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)argument- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich 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 retryingAbstractRetryingFilterBuilderwhich adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries.- Parameters:
initialDelay- DelayDurationfor the first retry and increased exponentially with each retryjitter- The jitter which is used as and offset toinitialDelayon each retrymaxDelay- The maximum amount of delay that will be introduced.- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich 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 retryingAbstractRetryingFilterBuilderwhich adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries.- Parameters:
initialDelay- DelayDurationfor the first retry and increased exponentially with each retryjitter- The jitter which is used as and offset toinitialDelayon each retrymaxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff. It takes precedence over an alternative timerExecutorfromAbstractRetryingFilterBuilder.ReadOnlyRetryableSettings.newStrategy(Executor)argument- Returns:
- A new retrying
AbstractRetryingFilterBuilderwhich adds an exponentially increasing delay between retries with jitter
-
build
protected abstract Filter build(AbstractRetryingFilterBuilder.ReadOnlyRetryableSettings<Meta> readOnlySettings)
Builds a retryingAbstractRetryingFilterBuilderfor 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)
-
-