Interface Timer
- All Known Implementing Classes:
TimerImpl
public interface Timer
Collects metrics of the decorated operation.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceAn EventPublisher which subscribes to the reactive stream of TimerEvents and can be used to register event consumers. -
Method Summary
Modifier and TypeMethodDescriptionCreates a Timer context and starts the timer.static <T> Callable<T>decorateCallable(Timer timer, Callable<T> callable) Decorates Callable with Timerstatic <T> io.github.resilience4j.core.functions.CheckedConsumer<T>decorateCheckedConsumer(Timer timer, io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Decorates CheckedConsumer with Timerstatic <T,R> io.github.resilience4j.core.functions.CheckedFunction<T, R> decorateCheckedFunction(Timer timer, io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Decorates CheckedFunction with Timerstatic io.github.resilience4j.core.functions.CheckedRunnabledecorateCheckedRunnable(Timer timer, io.github.resilience4j.core.functions.CheckedRunnable runnable) Decorates CheckedRunnable with Timerstatic <T> io.github.resilience4j.core.functions.CheckedSupplier<T>decorateCheckedSupplier(Timer timer, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Decorates CheckedSupplier with Timerstatic <T> Supplier<CompletionStage<T>>decorateCompletionStage(Timer timer, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier with Timerstatic <T> Consumer<T>decorateConsumer(Timer timer, Consumer<T> consumer) Decorates Consumer with Timerstatic <T,R> Function<T, R> decorateFunction(Timer timer, Function<T, R> function) Decorates Function with Timerstatic RunnabledecorateRunnable(Timer timer, Runnable runnable) Decorates Runnable with Timerstatic <T> Supplier<T>decorateSupplier(Timer timer, Supplier<T> supplier) Decorates Supplier with Timerdefault <T> TexecuteCallable(Callable<T> callable) Decorates and executes the decorated Callable.default <T> TexecuteCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> checkedSupplier) Decorates and executes the decorated Supplier.default <T> CompletionStage<T>executeCompletionStage(Supplier<CompletionStage<T>> supplier) Decorates and executes the decorated CompletionStage.default voidexecuteRunnable(Runnable runnable) Decorates and executes the decorated Runnable.default <T> TexecuteSupplier(Supplier<T> supplier) Decorates and executes the decorated Supplier.Returns an EventPublisher can be used to register event consumers.getName()Returns the name of this Timer.getTags()Returns an unmodifiable map with tags assigned to this Timer.Returns the TimerConfig of this Timer.static TimerCreates a Timer with a default Timer configuration.static Timerof(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig) Creates a Timer with a custom Timer configuration.static Timerof(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig, Map<String, String> tags) Creates a Timer with a custom Timer configuration.
-
Method Details
-
of
Creates a Timer with a default Timer configuration.- Parameters:
name- the name of the Timerregistry- the registry to bind Timer to- Returns:
- a Timer with a custom Timer configuration.
-
of
static Timer of(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig) Creates a Timer with a custom Timer configuration.- Parameters:
name- the name of the Timerregistry- the registry to bind Timer totimerConfig- a custom Timer configuration- Returns:
- a Timer with a custom Timer configuration.
-
of
static Timer of(String name, io.micrometer.core.instrument.MeterRegistry registry, TimerConfig timerConfig, Map<String, String> tags) Creates a Timer with a custom Timer configuration.- Parameters:
name- the name of the Timerregistry- the registry to bind Timer totimerConfig- a custom Timer configurationtags- tags to assign to the Timer- Returns:
- a Timer with a custom Timer configuration.
-
decorateCompletionStage
static <T> Supplier<CompletionStage<T>> decorateCompletionStage(Timer timer, Supplier<CompletionStage<T>> supplier) Decorates CompletionStageSupplier with Timer- Type Parameters:
T- type of completion stage result- Parameters:
timer- the timersupplier- completion stage supplier- Returns:
- decorated supplier
-
decorateCheckedSupplier
static <T> io.github.resilience4j.core.functions.CheckedSupplier<T> decorateCheckedSupplier(Timer timer, io.github.resilience4j.core.functions.CheckedSupplier<T> supplier) Decorates CheckedSupplier with Timer- Type Parameters:
T- the supplier result- Parameters:
timer- the timersupplier- the supplier- Returns:
- decorated supplier
-
decorateCheckedRunnable
static io.github.resilience4j.core.functions.CheckedRunnable decorateCheckedRunnable(Timer timer, io.github.resilience4j.core.functions.CheckedRunnable runnable) Decorates CheckedRunnable with Timer- Parameters:
timer- the timerrunnable- the original runnable- Returns:
- decorated runnable
-
decorateCheckedFunction
static <T,R> io.github.resilience4j.core.functions.CheckedFunction<T,R> decorateCheckedFunction(Timer timer, io.github.resilience4j.core.functions.CheckedFunction<T, R> function) Decorates CheckedFunction with Timer- Type Parameters:
T- the type of the input to the functionR- the result type of the function- Parameters:
timer- the timerfunction- the original function- Returns:
- a decorated function
-
decorateSupplier
Decorates Supplier with Timer- Type Parameters:
T- the type of results supplied by this supplier- Parameters:
timer- the timersupplier- the original supplier- Returns:
- a decorated supplier
-
decorateCallable
Decorates Callable with Timer- Type Parameters:
T- the type of results supplied by this callable- Parameters:
timer- the timercallable- the original callable- Returns:
- a decorated callable
-
decorateRunnable
Decorates Runnable with Timer- Parameters:
timer- the timerrunnable- the original runnable- Returns:
- a decorated runnable
-
decorateFunction
Decorates Function with Timer- Type Parameters:
T- the type of the input to the functionR- the result type of the function- Parameters:
timer- the timerfunction- the original function- Returns:
- a decorated function
-
decorateConsumer
Decorates Consumer with Timer- Type Parameters:
T- the type of the input to the consumer- Parameters:
timer- the timerconsumer- the original consumer- Returns:
- a decorated consumer
-
decorateCheckedConsumer
static <T> io.github.resilience4j.core.functions.CheckedConsumer<T> decorateCheckedConsumer(Timer timer, io.github.resilience4j.core.functions.CheckedConsumer<T> consumer) Decorates CheckedConsumer with Timer- Type Parameters:
T- the type of the input to the consumer- Parameters:
timer- the timerconsumer- the original consumer- Returns:
- a decorated consumer
-
getName
String getName()Returns the name of this Timer.- Returns:
- the name of this Timer
-
getTimerConfig
TimerConfig getTimerConfig()Returns the TimerConfig of this Timer.- Returns:
- the TimerConfig of this Timer
-
getTags
Returns an unmodifiable map with tags assigned to this Timer.- Returns:
- the tags assigned to this Timer in an unmodifiable map
-
executeCheckedSupplier
default <T> T executeCheckedSupplier(io.github.resilience4j.core.functions.CheckedSupplier<T> checkedSupplier) throws Throwable Decorates and executes the decorated Supplier.- Type Parameters:
T- the type of results supplied by this supplier- Parameters:
checkedSupplier- the original Supplier- Returns:
- the result of the decorated Supplier.
- Throws:
Throwable- if something goes wrong applying this function to the given arguments
-
executeSupplier
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.
-
executeCallable
Decorates and executes the decorated Callable.- Type Parameters:
T- the result type of callable- Parameters:
callable- the original Callable- Returns:
- the result of the decorated Callable.
- Throws:
Exception
-
executeRunnable
Decorates and executes the decorated Runnable.- Parameters:
runnable- the original Runnable
-
executeCompletionStage
Decorates and executes the decorated CompletionStage.- Type Parameters:
T- the type of results supplied by this supplier- Parameters:
supplier- the original CompletionStage- Returns:
- the decorated CompletionStage.
-
createContext
Timer.Context createContext()Creates a Timer context and starts the timer.- Returns:
- the Timer context
-
getEventPublisher
Timer.EventPublisher getEventPublisher()Returns an EventPublisher can be used to register event consumers.- Returns:
- an EventPublisher
-