Interface Scannable
- All Known Subinterfaces:
Sinks.Empty<T>,Sinks.Many<T>,Sinks.ManyWithUpstream<T>,Sinks.One<T>
- All Known Implementing Classes:
DirectProcessor,EmitterProcessor,FluxOperator,FluxProcessor,MonoOperator,MonoProcessor,Operators.DeferredSubscription,Operators.MonoSubscriber,ReplayProcessor,SinkOneSerialized,UnicastProcessor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Stream queries from
actuals(), parents() and inners(). This allows for
visiting patterns and possibly enable serviceability features.
Scannable is also a useful tool for the advanced user eager to learn which kind of state we usually manage in the package-scope schedulers or operators implementations.
- Author:
- Stephane Maldini
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBase class forScannableattributes, which all can define a meaningful default. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternThe pattern for matching words unrelated to operator name. -
Method Summary
Modifier and TypeMethodDescriptionactuals()Return aStreamnavigating theSubscriberchain (downward).static ScannableAttempt to cast the Object to aScannable.inners()Return aStreamof referenced inners (flatmap, multicast etc)default booleanReturn true whether the component is available forscan(Attr)resolution.default Stringname()Check thisScannableand itsparents()for a user-defined name and return the first one that is reachable, or default to thisScannablestepName()if none.parents()Return aStreamnavigating theSubscriptionchain (upward).default <T> @Nullable Tscan(Scannable.Attr<T> key) Introspect a component's specific stateattribute, returning an associated value specific to that component, or the default value associated with the key, or null if the attribute doesn't make sense for that particular component and has no sensible default.default <T> TscanOrDefault(Scannable.Attr<T> key, T defaultValue) Introspect a component's specific stateattribute.scanUnsafe(Scannable.Attr key) This method is used internally by components to define their key-value mappings in a single place.default StringstepName()steps()List the step names in the chain ofScannable(including the current element), in their assembly order.tags()Deprecated.
-
Field Details
-
OPERATOR_NAME_UNRELATED_WORDS_PATTERN
The pattern for matching words unrelated to operator name. Used to strip an operator name of various prefixes and suffixes.
-
-
Method Details
-
from
Attempt to cast the Object to aScannable. ReturnScannable.Attr.NULL_SCANif the value is null, orScannable.Attr.UNAVAILABLE_SCANif the value is not aScannable. Both are constantScannablethat return false onisScanAvailable(). -
actuals
- Returns:
- a
Streamnavigating theSubscriberchain (downward, currentScannablenot included).
-
inners
Return aStreamof referenced inners (flatmap, multicast etc)- Returns:
- a
Streamof referenced inners (flatmap, multicast etc)
-
isScanAvailable
default boolean isScanAvailable()Return true whether the component is available forscan(Attr)resolution.- Returns:
- true whether the component is available for
scan(Attr)resolution.
-
name
Check thisScannableand itsparents()for a user-defined name and return the first one that is reachable, or default to thisScannablestepName()if none.- Returns:
- the name of the first parent that has one defined (including this scannable)
-
stepName
-
steps
List the step names in the chain ofScannable(including the current element), in their assembly order. This traverses the chain ofScannableboth upstream (parents()) and downstream (actuals()).- if the current Scannable is a
Subscriber, the chain can reach down to the final subscriber, provided it isScannable(eg. lambda subscriber) - if it is an operator the chain can reach up to the source, if it is a Reactor
source (that is
Scannable).
- Returns:
- a
StreamofstepName()for each discovered step in theScannablechain
- if the current Scannable is a
-
parents
- Returns:
- a
Streamnavigating theSubscriptionchain (upward, currentScannablenot included).
-
scanUnsafe
This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of theScannable.Attrkey, implementors should take care to return values of the correct type, and return null if no specific value is available.For public consumption of attributes, prefer using
scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.- Parameters:
key- aScannable.Attrto resolve for the component.- Returns:
- the value associated to the key for that specific component, or null if none.
-
scan
Introspect a component's specific stateattribute, returning an associated value specific to that component, or the default value associated with the key, or null if the attribute doesn't make sense for that particular component and has no sensible default.- Parameters:
key- aScannable.Attrto resolve for the component.- Returns:
- a value associated to the key or null if unmatched or unresolved
-
scanOrDefault
Introspect a component's specific stateattribute. If there's no specific value in the component for that key, fall back to returning the provided non null default.- Parameters:
key- aScannable.Attrto resolve for the component.defaultValue- a fallback value if key resolve to null- Returns:
- a value associated to the key or the provided default if unmatched or unresolved
-
tags
Visit thisScannableand itsparents(), starting by the furthest reachable parent, and return aStreamof the tags which includes duplicates and outputs tags in declaration order (grandparent tag(s) > parent tag(s) > current tag(s)).Tags can only be discovered until no parent can be inspected, which happens either when the source publisher has been reached or when a non-reactor intermediate operator is present in the parent chain (i.e. a stage that is not
ScannableforScannable.Attr.PARENT).- Returns:
- the stream of tags for this
Scannableand its reachable parents, including duplicates - See Also:
-
tagsDeduplicated
Deprecated.Micrometer APIs generally deduplicate tags and key-value pairs by default, so for related use cases prefertags().Visit thisScannableand itsparents(), starting by the furthest reachable parent, deduplicate tags that have a common key by favoring the value declared last (current tag(s) > parent tag(s) > grandparent tag(s)) and return aMapof the deduplicated tags. Note that while the values are the "latest", the key iteration order reflects the tags' declaration order.Tags can only be discovered until no parent can be inspected, which happens either when the source publisher has been reached or when a non-reactor intermediate operator is present in the parent chain (i.e. a stage that is not
ScannableforScannable.Attr.PARENT).
-
tags().