Class TimeLimiterImpl

  • All Implemented Interfaces:
    TimeLimiter

    public class TimeLimiterImpl
    extends java.lang.Object
    implements TimeLimiter
    • 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.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.
      void onError​(java.lang.Throwable throwable)
      Records a failed call.
      void onSuccess()
      Records a successful call.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: TimeLimiter
        Creates a Callback that is restricted by a TimeLimiter.
        Specified by:
        decorateFutureSupplier in interface TimeLimiter
        Type Parameters:
        T - the type of results supplied by the supplier
        F - 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: TimeLimiter
        Decorate a CompletionStage supplier which is decorated by a TimeLimiter
        Specified by:
        decorateCompletionStage in interface TimeLimiter
        Type Parameters:
        T - the type of the returned CompletionStage's result
        F - the CompletionStage type supplied
        Parameters:
        scheduler - execution service to use to schedule timeout
        supplier - the original CompletionStage supplier
        Returns:
        a CompletionStage supplier which is decorated by a TimeLimiter
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface TimeLimiter
      • getTags

        public io.vavr.collection.Map<java.lang.String,​java.lang.String> getTags()
        Description copied from interface: TimeLimiter
        Returns an unmodifiable map with tags assigned to this TimeLimiter.
        Specified by:
        getTags in interface TimeLimiter
        Returns:
        the tags assigned to this TimeLimiter in an unmodifiable map
      • getTimeLimiterConfig

        public TimeLimiterConfig getTimeLimiterConfig()
        Description copied from interface: TimeLimiter
        Get the TimeLimiterConfig of this TimeLimiter decorator.
        Specified by:
        getTimeLimiterConfig in interface TimeLimiter
        Returns:
        the TimeLimiterConfig of this TimeLimiter decorator
      • onSuccess

        public void onSuccess()
        Description copied from interface: TimeLimiter
        Records a successful call.

        This method must be invoked when a call was successful.

        Specified by:
        onSuccess in interface TimeLimiter
      • onError

        public void onError​(java.lang.Throwable throwable)
        Description copied from interface: TimeLimiter
        Records a failed call. This method must be invoked when a call failed.
        Specified by:
        onError in interface TimeLimiter
        Parameters:
        throwable - The throwable which must be recorded