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.CompletionStage<T>> |
decorateCompletionStage(java.util.concurrent.ScheduledExecutorService scheduler,
java.util.function.Supplier<F> supplier)
Decorate a CompletionStage supplier which is decorated by a TimeLimiter
|
static <T,F extends java.util.concurrent.CompletionStage<T>> |
decorateCompletionStage(TimeLimiter timeLimiter,
java.util.concurrent.ScheduledExecutorService scheduler,
java.util.function.Supplier<F> supplier)
Decorate a CompletionStage supplier which is decorated by a TimeLimiter
|
<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.CompletionStage<T>> |
executeCompletionStage(java.util.concurrent.ScheduledExecutorService scheduler,
java.util.function.Supplier<F> supplier)
Decorates and executes the CompletionStage Supplier
|
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() |
io.vavr.collection.Map<java.lang.String,java.lang.String> |
getTags()
Returns an unmodifiable map with tags assigned to this TimeLimiter.
|
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(java.lang.String name,
TimeLimiterConfig timeLimiterConfig,
io.vavr.collection.Map<java.lang.String,java.lang.String> tags)
Creates a TimeLimiter with a custom TimeLimiter 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.
|
static TimeLimiter |
ofDefaults(java.lang.String name)
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 ofDefaults(java.lang.String name)
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.lang.String name, TimeLimiterConfig timeLimiterConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)
The tags passed will be appended to the tags already configured for the registry.
When tags (keys) of the two collide the tags passed with this method will override the tags
of the registry.
name - the name of the TimeLimitertimeLimiterConfig - a custom TimeLimiter configurationtags - tags added to the Retrystatic 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.static <T,F extends java.util.concurrent.CompletionStage<T>> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateCompletionStage(TimeLimiter timeLimiter, java.util.concurrent.ScheduledExecutorService scheduler, java.util.function.Supplier<F> supplier)
T - the type of the returned CompletionStage's resultF - the CompletionStage type suppliedtimeLimiter - the TimeLimiterscheduler - execution service to use to schedule timeoutsupplier - the original CompletionStage supplierjava.lang.String getName()
io.vavr.collection.Map<java.lang.String,java.lang.String> getTags()
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 resultdefault <T,F extends java.util.concurrent.CompletionStage<T>> java.util.concurrent.CompletionStage<T> executeCompletionStage(java.util.concurrent.ScheduledExecutorService scheduler,
java.util.function.Supplier<F> supplier)
T - the type of the returned CompletionStage's resultF - the CompletionStage type suppliedscheduler - execution service to use to schedule timeoutsupplier - the original CompletionStage supplier<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.<T,F extends java.util.concurrent.CompletionStage<T>> java.util.function.Supplier<java.util.concurrent.CompletionStage<T>> decorateCompletionStage(java.util.concurrent.ScheduledExecutorService scheduler,
java.util.function.Supplier<F> supplier)
T - the type of the returned CompletionStage's resultF - the CompletionStage type suppliedscheduler - execution service to use to schedule timeoutsupplier - the original CompletionStage supplierTimeLimiter.EventPublisher getEventPublisher()
void onSuccess()
This method must be invoked when a call was successful.
void onError(java.lang.Throwable throwable)
throwable - The throwable which must be recorded