Package io.micrometer.context
Class ContextScheduledExecutorService
java.lang.Object
io.micrometer.context.ContextExecutorService<ScheduledExecutorService>
io.micrometer.context.ContextScheduledExecutorService
- All Implemented Interfaces:
Executor
,ExecutorService
,ScheduledExecutorService
public final class ContextScheduledExecutorService
extends ContextExecutorService<ScheduledExecutorService>
implements ScheduledExecutorService
Wraps a
ScheduledExecutorService
in order to capture context via
ContextSnapshot
when a task is submitted, and propagate context to the task
when it is executed.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescription<V> ScheduledFuture<V>
scheduleAtFixedRate
(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay
(Runnable command, long initialDelay, long delay, TimeUnit unit) static ScheduledExecutorService
wrap
(ScheduledExecutorService service) Variant ofwrap(ScheduledExecutorService, Supplier)
that usesContextSnapshot.captureAll(Object...)
to create the context snapshot.static ScheduledExecutorService
wrap
(ScheduledExecutorService service, Supplier<ContextSnapshot> supplier) Wrap the givenScheduledExecutorService
in order to propagate context to any executed task through the givenContextSnapshot
supplier.Methods inherited from class io.micrometer.context.ContextExecutorService
awaitTermination, capture, execute, getExecutorService, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit, wrap, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Method Details
-
schedule
- Specified by:
schedule
in interfaceScheduledExecutorService
-
schedule
- Specified by:
schedule
in interfaceScheduledExecutorService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) - Specified by:
scheduleAtFixedRate
in interfaceScheduledExecutorService
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) - Specified by:
scheduleWithFixedDelay
in interfaceScheduledExecutorService
-
wrap
public static ScheduledExecutorService wrap(ScheduledExecutorService service, Supplier<ContextSnapshot> supplier) Wrap the givenScheduledExecutorService
in order to propagate context to any executed task through the givenContextSnapshot
supplier.- Parameters:
service
- the executorService to wrapsupplier
- supplier for capturing aContextSnapshot
at the point when tasks are scheduled
-
wrap
Variant ofwrap(ScheduledExecutorService, Supplier)
that usesContextSnapshot.captureAll(Object...)
to create the context snapshot.- Parameters:
service
- the executorService to wrap
-