S
- self typeC
- config typeR
- result typepublic abstract class DelayablePolicyBuilder<S,C extends DelayablePolicyConfig<R>,R> extends FailurePolicyBuilder<S,C,R>
config
Modifier | Constructor and Description |
---|---|
protected |
DelayablePolicyBuilder(C config) |
Modifier and Type | Method and Description |
---|---|
S |
withDelay(Duration delay)
Sets the
delay to occur between execution attempts. |
S |
withDelayFn(ContextualSupplier<R,Duration> delayFunction)
Sets the
delayFunction that computes the next delay before allowing another execution. |
<F extends Throwable> |
withDelayFnOn(ContextualSupplier<R,Duration> delayFunction,
Class<F> exception)
Sets the
delayFunction that computes the next delay before allowing another execution. |
S |
withDelayFnWhen(ContextualSupplier<R,Duration> delayFunction,
R result)
Sets the
delayFunction that computes the next delay before allowing another execution. |
handle, handle, handle, handleIf, handleIf, handleResult, handleResultIf
onFailure, onSuccess
protected DelayablePolicyBuilder(C config)
public S withDelay(Duration delay)
delay
to occur between execution attempts.NullPointerException
- if delay
is nullIllegalArgumentException
- if delay
<= 0public S withDelayFn(ContextualSupplier<R,Duration> delayFunction)
delayFunction
that computes the next delay before allowing another execution.
The delayFunction
must complete quickly, not have side-effects, and always return the same result for the
same input. Exceptions thrown by the delayFunction
method will not be handled and will
cause Failsafe's execution to abort.
Notes:
ExecutionContext
that is provided to the delayFunction
may be null
if the prior execution
exception was manually recorded outside of a Failsafe execution.NullPointerException
- if delayFunction
is nullpublic <F extends Throwable> S withDelayFnOn(ContextualSupplier<R,Duration> delayFunction, Class<F> exception)
delayFunction
that computes the next delay before allowing another execution. Delays will only
occur for exceptions that are assignable from the exception
.
The delayFunction
must complete quickly, not have side-effects, and always return the same result for the
same input. Exceptions thrown by the delayFunction
method will not be handled and will
cause Failsafe's execution to abort.
Notes:
ExecutionContext
that is provided to the delayFunction
may be null
if the prior execution
exception was manually recorded outside of a Failsafe execution.F
- exception typedelayFunction
- the function to use to compute the delay before a next attemptexception
- the execution exception that is expected in order to trigger the delayNullPointerException
- if delayFunction
or exception
are nullpublic S withDelayFnWhen(ContextualSupplier<R,Duration> delayFunction, R result)
delayFunction
that computes the next delay before allowing another execution. Delays will only
occur for results that equal the result
.
The delayFunction
must complete quickly, not have side-effects, and always return the same result for the
same input. Exceptions thrown by the delayFunction
method will not be handled and will
cause Failsafe's execution to abort.
Notes:
ExecutionContext
that is provided to the delayFunction
may be null
if the prior execution
exception was manually recorded outside of a Failsafe execution.delayFunction
- the function to use to compute the delay before a next attemptresult
- the execution result that is expected in order to trigger the delayNullPointerException
- if delayFunction
or result
are nullCopyright © 2022. All rights reserved.