public interface TimeLimiter
| Modifier and Type | Interface and Description |
|---|---|
static interface |
TimeLimiter.EventPublisher
An EventPublisher which can be used to register event consumers.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_NAME |
| Modifier and Type | Method and Description |
|---|---|
<T,F extends java.util.concurrent.Future<T>> |
decorateFutureSupplier(java.util.function.Supplier<F> futureSupplier)
Creates a Callback that is restricted by a TimeLimiter.
|
static <T,F extends java.util.concurrent.Future<T>> |
decorateFutureSupplier(TimeLimiter timeLimiter,
java.util.function.Supplier<F> futureSupplier)
Creates a Callback that is restricted by a TimeLimiter.
|
default <T,F extends java.util.concurrent.Future<T>> |
executeFutureSupplier(java.util.function.Supplier<F> futureSupplier)
Decorates and executes the Future Supplier.
|
TimeLimiter.EventPublisher |
getEventPublisher()
Returns an EventPublisher which can be used to register event consumers.
|
java.lang.String |
getName() |
TimeLimiterConfig |
getTimeLimiterConfig()
Get the TimeLimiterConfig of this TimeLimiter decorator.
|
static TimeLimiter |
of(java.time.Duration timeoutDuration)
Creates a TimeLimiter decorator with a timeout Duration.
|
static TimeLimiter |
of(java.lang.String name,
TimeLimiterConfig timeLimiterConfig)
Creates a TimeLimiter decorator with a TimeLimiterConfig configuration.
|
static TimeLimiter |
of(TimeLimiterConfig timeLimiterConfig)
Creates a TimeLimiter decorator with a TimeLimiterConfig configuration.
|
static TimeLimiter |
ofDefaults()
Creates a TimeLimiter decorator with a default TimeLimiterConfig configuration.
|
void |
onError(java.lang.Throwable throwable)
Records a failed call.
|
void |
onSuccess()
Records a successful call.
|
static final java.lang.String DEFAULT_NAME
static TimeLimiter ofDefaults()
TimeLimiterstatic TimeLimiter of(TimeLimiterConfig timeLimiterConfig)
timeLimiterConfig - the TimeLimiterConfigTimeLimiterstatic TimeLimiter of(java.lang.String name, TimeLimiterConfig timeLimiterConfig)
name - the name of the TimeLimitertimeLimiterConfig - the TimeLimiterConfigTimeLimiterstatic TimeLimiter of(java.time.Duration timeoutDuration)
timeoutDuration - the timeout DurationTimeLimiterstatic <T,F extends java.util.concurrent.Future<T>> java.util.concurrent.Callable<T> decorateFutureSupplier(TimeLimiter timeLimiter, java.util.function.Supplier<F> futureSupplier)
T - the type of results supplied by the supplierF - the future type suppliedtimeLimiter - the TimeLimiterfutureSupplier - the original future supplierTimeLimiter.java.lang.String getName()
TimeLimiterConfig getTimeLimiterConfig()
default <T,F extends java.util.concurrent.Future<T>> T executeFutureSupplier(java.util.function.Supplier<F> futureSupplier)
throws java.lang.Exception
T - the result type of the futureF - the type of FuturefutureSupplier - the original future supplierjava.lang.Exception - if unable to compute a result<T,F extends java.util.concurrent.Future<T>> java.util.concurrent.Callable<T> decorateFutureSupplier(java.util.function.Supplier<F> futureSupplier)
T - the type of results supplied by the supplierF - the future type suppliedfutureSupplier - the original future supplierTimeLimiter.TimeLimiter.EventPublisher getEventPublisher()
void onSuccess()
void onError(java.lang.Throwable throwable)
throwable - The throwable which must be recorded