Package io.smallrye.faulttolerance.api
Interface CustomBackoffStrategy
-
@Experimental("first attempt at providing additional retry backoff strategies") public interface CustomBackoffStrategyFor each invocation of a method annotated@Retryand@CustomBackoff, an instance of custom backoff strategy is created and used for computing delays between individual retry attempts. Therefore, implementations of this interface must have a public zero-parameter constructor and should generally be cheap to construct and not use a lot of memory. Additionally, they may be used from multiple threads, so they must be thread safe.- See Also:
init(long),nextDelayInMillis(Throwable),CustomBackoff
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidinit(long initialDelayInMillis)Called once, after instantiation.longnextDelayInMillis(Throwable exception)Called to compute a delay before each retry attempt, including before the first retry.
-
-
-
Method Detail
-
init
default void init(long initialDelayInMillis)
Called once, after instantiation. Can be used to initialize state, if needed. Implementations are free to useinitialDelayInMillisas they see fit; possibly even ignore, if the concept of initial delay doesn't make sense for the strategy.- Parameters:
initialDelayInMillis- initial delay in milliseconds, perRetry.delayandRetry.delayUnit
-
nextDelayInMillis
long nextDelayInMillis(Throwable exception)
Called to compute a delay before each retry attempt, including before the first retry. Implementations must be fast and non-blocking (i.e., they must not do any IO or long-running computations).- Parameters:
exception- exception that caused the retry attempt- Returns:
- delay in milliseconds; must be
>= 0
-
-