T - what is returnedpublic abstract class Retryable<T>
extends java.lang.Object
runImpl by means of exponential back-off.| Modifier and Type | Field and Description |
|---|---|
static short |
FAIL_ON_EXCEPTION
Marks that this should fail on exceptions by
propagating said exception.
|
| Constructor and Description |
|---|
Retryable(java.lang.String name,
java.util.List<java.lang.Runnable> failCallbacks,
short... params)
Instantiates a new retryable.
|
Retryable(java.lang.String name,
java.lang.Runnable failCallback,
short... params)
Convenience constructor for retryables that have exactly one fail
callback.
|
Retryable(java.lang.String name,
short... params)
Convenience constructor for retryables with no runnable failure
callbacks.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
onFailure()
Called after an exception is thrown or null is returned
from runImpl
|
T |
run()
Runs runImpl at most 10 times or until the result is non-null.
|
protected abstract T |
runImpl()
Run impl.
|
public static final short FAIL_ON_EXCEPTION
public Retryable(java.lang.String name,
java.util.List<java.lang.Runnable> failCallbacks,
short... params)
name - the name of the action being attempted, for debuggingfailCallbacks - callbacks in the event of failure. may be nullparams - optional constants that affect the behavior of the retryablepublic Retryable(java.lang.String name,
java.lang.Runnable failCallback,
short... params)
name - the name of the action being attempted, for debuggingfailCallback - the callback in the event of failure. May be nullparams - optional constants that affect the behavior of the retryablepublic Retryable(java.lang.String name,
short... params)
name - the name of the action being attempted, for debuggingparams - optional constants that affect the behavior of the retryablepublic T run()
protected abstract T runImpl() throws java.lang.Exception
java.lang.Exceptionprotected void onFailure()