Package io.micrometer.context
Interface ContextAccessor<READ,WRITE>
- Type Parameters:
READ- type of context for readingWRITE- type of context for writing
public interface ContextAccessor<READ,WRITE>
Contract to assist with access to an external, map-like context, such as the Project
Reactor
Context, including the ability to read values from it a Map and
to write values to it from a Map.- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionClassrepresenting the type of context this accessor is capable of reading values from.<T> TRead a single value from the source context.voidRead values from a source context into aMap.Classrepresenting the type of context this accessor can restore values to.writeValues(Map<Object, Object> valuesToWrite, WRITE targetContext) Write values from aMapto a target context.
-
Method Details
-
readableType
Classrepresenting the type of context this accessor is capable of reading values from. -
readValues
Read values from a source context into aMap.- Parameters:
sourceContext- the context to read from; the context type should beassignablefrom the type returned byreadableType().keyPredicate- a predicate to decide which keys to readreadValues- a map where to put read values
-
readValue
Read a single value from the source context.- Parameters:
sourceContext- the context to read from; the context type should beassignablefrom the type returned byreadableType().key- the key to use to look up the context value- Returns:
- the value, if any
-
writeableType
Classrepresenting the type of context this accessor can restore values to. -
writeValues
Write values from aMapto a target context.- Parameters:
valuesToWrite- the values to write to the target contexttargetContext- the context to write to; the context type should beassignablefrom the type returned bywriteableType().- Returns:
- a context with the written values
-