Class TimeLimiterImpl
- java.lang.Object
-
- io.github.resilience4j.timelimiter.internal.TimeLimiterImpl
-
- All Implemented Interfaces:
TimeLimiter
public class TimeLimiterImpl extends java.lang.Object implements TimeLimiter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.github.resilience4j.timelimiter.TimeLimiter
TimeLimiter.EventPublisher
-
-
Field Summary
-
Fields inherited from interface io.github.resilience4j.timelimiter.TimeLimiter
DEFAULT_NAME
-
-
Constructor Summary
Constructors Constructor Description TimeLimiterImpl(java.lang.String name, TimeLimiterConfig timeLimiterConfig)TimeLimiterImpl(java.lang.String name, TimeLimiterConfig timeLimiterConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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)Decorate a CompletionStage supplier which is decorated by a TimeLimiter<T,F extends java.util.concurrent.Future<T>>
java.util.concurrent.Callable<T>decorateFutureSupplier(java.util.function.Supplier<F> futureSupplier)Creates a Callback that is restricted by a TimeLimiter.TimeLimiter.EventPublishergetEventPublisher()Returns an EventPublisher which can be used to register event consumers.java.lang.StringgetName()io.vavr.collection.Map<java.lang.String,java.lang.String>getTags()Returns an unmodifiable map with tags assigned to this TimeLimiter.TimeLimiterConfiggetTimeLimiterConfig()Get the TimeLimiterConfig of this TimeLimiter decorator.voidonError(java.lang.Throwable throwable)Records a failed call.voidonSuccess()Records a successful call.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.resilience4j.timelimiter.TimeLimiter
executeCompletionStage, executeFutureSupplier
-
-
-
-
Constructor Detail
-
TimeLimiterImpl
public TimeLimiterImpl(java.lang.String name, TimeLimiterConfig timeLimiterConfig)
-
TimeLimiterImpl
public TimeLimiterImpl(java.lang.String name, TimeLimiterConfig timeLimiterConfig, io.vavr.collection.Map<java.lang.String,java.lang.String> tags)
-
-
Method Detail
-
decorateFutureSupplier
public <T,F extends java.util.concurrent.Future<T>> java.util.concurrent.Callable<T> decorateFutureSupplier(java.util.function.Supplier<F> futureSupplier)
Description copied from interface:TimeLimiterCreates a Callback that is restricted by a TimeLimiter.- Specified by:
decorateFutureSupplierin interfaceTimeLimiter- Type Parameters:
T- the type of results supplied by the supplierF- the future type supplied- Parameters:
futureSupplier- the original future supplier- Returns:
- a future supplier which is restricted by a
TimeLimiter.
-
decorateCompletionStage
public <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)Description copied from interface:TimeLimiterDecorate a CompletionStage supplier which is decorated by a TimeLimiter- Specified by:
decorateCompletionStagein interfaceTimeLimiter- Type Parameters:
T- the type of the returned CompletionStage's resultF- the CompletionStage type supplied- Parameters:
scheduler- execution service to use to schedule timeoutsupplier- the original CompletionStage supplier- Returns:
- a CompletionStage supplier which is decorated by a TimeLimiter
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceTimeLimiter
-
getTags
public io.vavr.collection.Map<java.lang.String,java.lang.String> getTags()
Description copied from interface:TimeLimiterReturns an unmodifiable map with tags assigned to this TimeLimiter.- Specified by:
getTagsin interfaceTimeLimiter- Returns:
- the tags assigned to this TimeLimiter in an unmodifiable map
-
getTimeLimiterConfig
public TimeLimiterConfig getTimeLimiterConfig()
Description copied from interface:TimeLimiterGet the TimeLimiterConfig of this TimeLimiter decorator.- Specified by:
getTimeLimiterConfigin interfaceTimeLimiter- Returns:
- the TimeLimiterConfig of this TimeLimiter decorator
-
getEventPublisher
public TimeLimiter.EventPublisher getEventPublisher()
Description copied from interface:TimeLimiterReturns an EventPublisher which can be used to register event consumers.- Specified by:
getEventPublisherin interfaceTimeLimiter- Returns:
- an EventPublisher
-
onSuccess
public void onSuccess()
Description copied from interface:TimeLimiterRecords a successful call.This method must be invoked when a call was successful.
- Specified by:
onSuccessin interfaceTimeLimiter
-
onError
public void onError(java.lang.Throwable throwable)
Description copied from interface:TimeLimiterRecords a failed call. This method must be invoked when a call failed.- Specified by:
onErrorin interfaceTimeLimiter- Parameters:
throwable- The throwable which must be recorded
-
-