Top Description Inners Fields Methods
io.github.resilience4j.core

public Interface ContextPropagator<T>

Known Direct Implementers
io.github.resilience4j.core.ContextPropagator.EmptyContextPropagator
Type Parameters
<T>
value type that is copied across thread boundary.
Imports
java.util.*, java.util.concurrent.Callable, java.util.function.Consumer, .Supplier

Abstraction to retrieve, copy and clean up values across thread boundary. This class is specifically use for propagating ThreadLocal across different thread boundaries.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ContextPropagator.EmptyContextPropagator<
type of class.
T
>

A convenient implementation of empty ContextPropagator

Field Summary

Modifier and TypeField and Description
public static final String

Method Summary

Modifier and TypeMethod and Description
public Consumer<Optional<T>>

Returns:

a Consumer to cleanUp values.
clear
()

CleanUp value before thread execution finish.

public Consumer<Optional<T>>

Returns:

a Consumer to set values in new thread.
copy
()

Copies value from the parent thread into new executing thread.

public static <
the type of variable that cross thread boundary
T
>
Callable<T>

Returns:

decorated callable of type T
decorateCallable
(ContextPropagator<T>
the instance of ContextPropagator
propagator
,
Callable<T>
the callable to be decorated
callable
)

Method decorates callable to copy variables across thread boundary.

public static <
the type of variable that cross thread boundary
T
>
Callable<T>

Returns:

decorated callable of type T
decorateCallable
(List<? extends ContextPropagator<T>>
the instance of ContextPropagator should be non null.
propagators
,
Callable<T>
the callable to be decorated
callable
)

Method decorates callable to copy variables across thread boundary.

public static <
the type of variable that cross thread boundary
T
>
Runnable

Returns:

decorated supplier of type T
decorateRunnable
(List<? extends ContextPropagator<T>>
the instance of ContextPropagator
propagators
,
Runnable
the runnable to be decorated
runnable
)

Method decorates runnable to copy variables across thread boundary.

public static <
the type of variable that cross thread boundary
T
>
Runnable

Returns:

decorated supplier of type T
decorateRunnable
(ContextPropagator<T>
the instance of ContextPropagator
propagator
,
Runnable
the runnable to be decorated
runnable
)

Method decorates runnable to copy variables across thread boundary.

public static <
the type of variable that cross thread boundary
T
>
Supplier<T>

Returns:

decorated supplier of type T
decorateSupplier
(ContextPropagator<T>
the instance of ContextPropagator
propagator
,
Supplier<T>
the supplier to be decorated
supplier
)

Method decorates supplier to copy variables across thread boundary.

public static <
the type of variable that cross thread boundary
T
>
Supplier<T>

Returns:

decorated supplier of type T
decorateSupplier
(List<? extends ContextPropagator<T>>
the instance of ContextPropagator should be non null.
propagators
,
Supplier<T>
the supplier to be decorated
supplier
)

Method decorates supplier to copy variables across thread boundary.

public static <
type.
T
>
ContextPropagator<T>

Returns:

an empty ContextPropagator
empty
()

An empty context propagator.

public Supplier<Optional<T>>

Returns:

a Supplier producing the value from current thread
retrieve
()

Retrieves value from the currently executing thread.

Field Detail

CONTEXT_PROPAGATOR_LIST_SHOULD_BE_NON_NULLback to summary
public static final String CONTEXT_PROPAGATOR_LIST_SHOULD_BE_NON_NULL

Method Detail

clearback to summary
public Consumer<Optional<T>> clear()

CleanUp value before thread execution finish. This method is passed with the values received from method ContextPropagator#retrieve() in the parent thread.

Returns:Consumer<Optional<T>>

a Consumer to cleanUp values.

copyback to summary
public Consumer<Optional<T>> copy()

Copies value from the parent thread into new executing thread. This method is passed with the values received from method ContextPropagator#retrieve() in the parent thread.

Returns:Consumer<Optional<T>>

a Consumer to set values in new thread.

decorateCallableback to summary
public static <T> Callable<T> decorateCallable(ContextPropagator<T> propagator, Callable<T> callable)

Method decorates callable to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagator:ContextPropagator<T>

the instance of ContextPropagator

callable:Callable<T>

the callable to be decorated

Returns:Callable<T>

decorated callable of type T

decorateCallableback to summary
public static <T> Callable<T> decorateCallable(List<? extends ContextPropagator<T>> propagators, Callable<T> callable)

Method decorates callable to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagators:List<? extends ContextPropagator<T>>

the instance of ContextPropagator should be non null.

callable:Callable<T>

the callable to be decorated

Returns:Callable<T>

decorated callable of type T

decorateRunnableback to summary
public static <T> Runnable decorateRunnable(List<? extends ContextPropagator<T>> propagators, Runnable runnable)

Method decorates runnable to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagators:List<? extends ContextPropagator<T>>

the instance of ContextPropagator

runnable:Runnable

the runnable to be decorated

Returns:Runnable

decorated supplier of type T

decorateRunnableback to summary
public static <T> Runnable decorateRunnable(ContextPropagator<T> propagator, Runnable runnable)

Method decorates runnable to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagator:ContextPropagator<T>

the instance of ContextPropagator

runnable:Runnable

the runnable to be decorated

Returns:Runnable

decorated supplier of type T

decorateSupplierback to summary
public static <T> Supplier<T> decorateSupplier(ContextPropagator<T> propagator, Supplier<T> supplier)

Method decorates supplier to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagator:ContextPropagator<T>

the instance of ContextPropagator

supplier:Supplier<T>

the supplier to be decorated

Returns:Supplier<T>

decorated supplier of type T

decorateSupplierback to summary
public static <T> Supplier<T> decorateSupplier(List<? extends ContextPropagator<T>> propagators, Supplier<T> supplier)

Method decorates supplier to copy variables across thread boundary.

Parameters
<T>
the type of variable that cross thread boundary
propagators:List<? extends ContextPropagator<T>>

the instance of ContextPropagator should be non null.

supplier:Supplier<T>

the supplier to be decorated

Returns:Supplier<T>

decorated supplier of type T

emptyback to summary
public static <T> ContextPropagator<T> empty()

An empty context propagator.

Parameters
<T>
type.
Returns:ContextPropagator<T>

an empty ContextPropagator

retrieveback to summary
public Supplier<Optional<T>> retrieve()

Retrieves value from the currently executing thread. This method should produce values (as Supplier) that needs to be propagated to new thread.

Returns:Supplier<Optional<T>>

a Supplier producing the value from current thread

io.github.resilience4j.core back to summary

public Class ContextPropagator.EmptyContextPropagator<T>

extends Object
implements ContextPropagator<T>
Class Inheritance
  • java.lang.Object
  • io.github.resilience4j.core.ContextPropagator.EmptyContextPropagator
All Implemented Interfaces
io.github.resilience4j.core.ContextPropagator
Type Parameters
<T>
type of class.

A convenient implementation of empty ContextPropagator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Consumer<Optional<T>>
clear()

Implements io.github.resilience4j.core.ContextPropagator.clear.

CleanUp value before thread execution finish.

public Consumer<Optional<T>>
copy()

Implements io.github.resilience4j.core.ContextPropagator.copy.

Copies value from the parent thread into new executing thread.

public Supplier<Optional<T>>
retrieve()

Implements io.github.resilience4j.core.ContextPropagator.retrieve.

Retrieves value from the currently executing thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EmptyContextPropagatorback to summary
public EmptyContextPropagator()

Method Detail

clearback to summary
public Consumer<Optional<T>> clear()

Implements io.github.resilience4j.core.ContextPropagator.clear.

Doc from io.github.resilience4j.core.ContextPropagator.clear.

CleanUp value before thread execution finish. This method is passed with the values received from method ContextPropagator#retrieve() in the parent thread.

Returns:Consumer<Optional<T>>

a Consumer to cleanUp values.

Annotations
@Override
copyback to summary
public Consumer<Optional<T>> copy()

Implements io.github.resilience4j.core.ContextPropagator.copy.

Doc from io.github.resilience4j.core.ContextPropagator.copy.

Copies value from the parent thread into new executing thread. This method is passed with the values received from method ContextPropagator#retrieve() in the parent thread.

Returns:Consumer<Optional<T>>

a Consumer to set values in new thread.

Annotations
@Override
retrieveback to summary
public Supplier<Optional<T>> retrieve()

Implements io.github.resilience4j.core.ContextPropagator.retrieve.

Doc from io.github.resilience4j.core.ContextPropagator.retrieve.

Retrieves value from the currently executing thread. This method should produce values (as Supplier) that needs to be propagated to new thread.

Returns:Supplier<Optional<T>>

a Supplier producing the value from current thread

Annotations
@Override