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 TypeMethodDescriptionClass
representing the type of context this accessor is capable of reading values from.<T> T
Read a single value from the source context.void
Read values from a source context into aMap
.Class
representing the type of context this accessor can restore values to.writeValues
(Map<Object, Object> valuesToWrite, WRITE targetContext) Write values from aMap
to a target context.
-
Method Details
-
readableType
Class
representing 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 beassignable
from the type returned byreadableType()
.When an
ContextAccessor
is used to populate aContextSnapshot
, the snapshot implementations are required to filter outnull
mappings, so it is not required to implement special handling in the accessor.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 beassignable
from the type returned byreadableType()
.key
- the key to use to look up the context value- Returns:
- the value, if present
-
writeableType
Class
representing the type of context this accessor can restore values to. -
writeValues
Write values from aMap
to a target context.- Parameters:
valuesToWrite
- the values to write to the target context.targetContext
- the context to write to; the context type should beassignable
from the type returned bywriteableType()
.- Returns:
- a context with the written values
-