@FunctionalInterface public interface Scannable
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.
Modifier and Type | Interface and Description |
---|---|
static class |
Scannable.Attr<T>
Base class for
Scannable attributes, which all can define a meaningful
default. |
Modifier and Type | Field and Description |
---|---|
static Pattern |
OPERATOR_NAME_UNRELATED_WORDS_PATTERN
The pattern for matching words unrelated to operator name.
|
Modifier and Type | Method and Description |
---|---|
default Stream<? extends Scannable> |
actuals()
Return a
Stream navigating the Subscriber
chain (downward). |
static Scannable |
from(Object o)
Attempt to cast the Object to a
Scannable . |
default Stream<? extends Scannable> |
inners()
Return a
Stream of referenced inners (flatmap, multicast etc) |
default boolean |
isScanAvailable()
Return true whether the component is available for
scan(Attr) resolution. |
default String |
name()
Check this
Scannable and its parents() for a user-defined name and
return the first one that is reachable, or default to this Scannable
stepName() if none. |
default Stream<? extends Scannable> |
parents()
Return a
Stream navigating the Subscription
chain (upward). |
default <T> T |
scan(Scannable.Attr<T> key)
Introspect a component's specific state
attribute , 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> T |
scanOrDefault(Scannable.Attr<T> key,
T defaultValue)
Introspect a component's specific state
attribute . |
Object |
scanUnsafe(Scannable.Attr key)
This method is used internally by components to define their key-value mappings
in a single place.
|
default String |
stepName()
|
default Stream<String> |
steps()
List the step names in the chain of
Scannable (including the current element),
in their assembly order. |
default Stream<Tuple2<String,String>> |
tags()
|
default Map<String,String> |
tagsDeduplicated()
|
static final Pattern OPERATOR_NAME_UNRELATED_WORDS_PATTERN
static Scannable from(@Nullable Object o)
Scannable
. Return Scannable.Attr.NULL_SCAN
if
the value is null, or Scannable.Attr.UNAVAILABLE_SCAN
if the value is not a Scannable
.
Both are constant Scannable
that return false on isScanAvailable()
.default Stream<? extends Scannable> actuals()
Stream
navigating the Subscriber
chain (downward, current Scannable
not included).default Stream<? extends Scannable> inners()
Stream
of referenced inners (flatmap, multicast etc)Stream
of referenced inners (flatmap, multicast etc)default boolean isScanAvailable()
scan(Attr)
resolution.scan(Attr)
resolution.default String name()
Scannable
and its parents()
for a user-defined name and
return the first one that is reachable, or default to this Scannable
stepName()
if none.default String stepName()
default Stream<String> steps()
Scannable
(including the current element),
in their assembly order. This traverses the chain of Scannable
both upstream
(parents()
) and downstream (actuals()
).
Subscriber
, the chain can reach down to
the final subscriber, provided it is Scannable
(eg. lambda subscriber)Scannable
).Stream
of stepName()
for each discovered step in the Scannable
chaindefault Stream<? extends Scannable> parents()
Stream
navigating the Subscription
chain (upward, current Scannable
not included).@Nullable Object scanUnsafe(Scannable.Attr key)
Scannable.Attr
key,
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.
key
- a Scannable.Attr
to resolve for the component.@Nullable default <T> T scan(Scannable.Attr<T> key)
attribute
, 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.key
- a Scannable.Attr
to resolve for the component.default <T> T scanOrDefault(Scannable.Attr<T> key, T defaultValue)
attribute
. If there's no
specific value in the component for that key, fall back to returning the
provided non null default.key
- a Scannable.Attr
to resolve for the component.defaultValue
- a fallback value if key resolve to nulldefault Stream<Tuple2<String,String>> tags()
Scannable
and its parents()
, starting by the furthest reachable parent,
and return a Stream
of 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 Scannable
for Scannable.Attr.PARENT
).
Scannable
and its reachable parents, including duplicatestagsDeduplicated()
default Map<String,String> tagsDeduplicated()
Scannable
and its parents()
, 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 a Map
of 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 Scannable
for Scannable.Attr.PARENT
).