Interface Timer

All Known Implementing Classes:
TimerImpl

public interface Timer
  • Method Details

    • ofMetricRegistry

      static Timer ofMetricRegistry(String name, com.codahale.metrics.MetricRegistry metricRegistry)
      Creates a timer of a provided MetricRegistry
      Parameters:
      name - the name of the timer
      metricRegistry - the MetricRegistry
      Returns:
      a Timer instance
    • of

      static Timer of(String name)
      Creates a timer of a default MetricRegistry
      Parameters:
      name - the name of the timer
      Returns:
      a Timer instance
    • decorateCheckedSupplier

      static <T> io.github.resilience4j.core.functions.CheckedSupplier<T> decorateCheckedSupplier(Timer timer, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier)
      Creates a timed checked supplier.
      Parameters:
      timer - the timer to use
      supplier - the original supplier
      Returns:
      a timed supplier
    • decorateCheckedRunnable

      static io.github.resilience4j.core.functions.CheckedRunnable decorateCheckedRunnable(Timer timer, io.github.resilience4j.core.functions.CheckedRunnable runnable)
      Creates a timed runnable.
      Parameters:
      timer - the timer to use
      runnable - the original runnable
      Returns:
      a timed runnable
    • decorateSupplier

      static <T> Supplier<T> decorateSupplier(Timer timer, Supplier<T> supplier)
      Creates a timed checked supplier.
      Parameters:
      timer - the timer to use
      supplier - the original supplier
      Returns:
      a timed supplier
    • decorateCallable

      static <T> Callable<T> decorateCallable(Timer timer, Callable<T> callable)
      Creates a timed Callable.
      Parameters:
      timer - the timer to use
      callable - the original Callable
      Returns:
      a timed Callable
    • decorateRunnable

      static Runnable decorateRunnable(Timer timer, Runnable runnable)
      Creates a timed runnable.
      Parameters:
      timer - the timer to use
      runnable - the original runnable
      Returns:
      a timed runnable
    • decorateFunction

      static <T,R> Function<T,R> decorateFunction(Timer timer, Function<T,R> function)
      Creates a timed function.
      Parameters:
      timer - the timer to use
      function - the original function
      Returns:
      a timed function
    • decorateCheckedFunction

      static <T,R> io.github.resilience4j.core.functions.CheckedFunction<T,R> decorateCheckedFunction(Timer timer, io.github.resilience4j.core.functions.CheckedFunction<T,R> function)
      Creates a timed function.
      Parameters:
      timer - the timer to use
      function - the original function
      Returns:
      a timed function
    • decorateCompletionStageSupplier

      static <T> Supplier<CompletionStage<T>> decorateCompletionStageSupplier(Timer timer, Supplier<CompletionStage<T>> stageSupplier)
      Parameters:
      timer - the timer to use
      stageSupplier - the CompletionStage Supplier
      Returns:
      a decorated completion stage
    • context

      Timer.Context context()
      Creates a Timer context and starts the timer
      Returns:
      the Timer context
    • getName

      String getName()
      Returns the name of this Timer.
      Returns:
      the name of this Timer
    • getMetricRegistry

      com.codahale.metrics.MetricRegistry getMetricRegistry()
      Returns the MetricRegistry of this Timer.
      Returns:
      the MetricRegistry of this Timer
    • getMetrics

      Timer.Metrics getMetrics()
      Returns the Metrics of this Timer.
      Returns:
      the Metrics of this Timer
    • executeRunnable

      default void executeRunnable(Runnable runnable)
      Decorates and executes the decorated Runnable.
      Parameters:
      runnable - the original Callable
    • executeCallable

      default <T> T executeCallable(Callable<T> callable) throws Exception
      Decorates and executes the decorated Callable.
      Type Parameters:
      T - the type of results supplied by this Callable
      Parameters:
      callable - the original Callable
      Returns:
      the result of the decorated Callable.
      Throws:
      Exception
    • executeSupplier

      default <T> T executeSupplier(Supplier<T> supplier)
      Decorates and executes the decorated Supplier.
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      supplier - the original Supplier
      Returns:
      the result of the decorated Supplier.
    • executeCompletionStageSupplier

      default <T> CompletionStage<T> executeCompletionStageSupplier(Supplier<CompletionStage<T>> supplier)
      Decorates and executes the decorated CompletionStage Supplier.
      Type Parameters:
      T - the type of results supplied by this supplier
      Parameters:
      supplier - the CompletionStage Supplier
      Returns:
      the result of the decorated Supplier.