@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.
限定符和类型 | 接口和说明 |
---|---|
static class |
Scannable.Attr<T>
Base class for
Scannable attributes, which all can define a meaningful
default. |
限定符和类型 | 字段和说明 |
---|---|
static java.util.regex.Pattern |
OPERATOR_NAME_UNRELATED_WORDS_PATTERN
The pattern for matching words unrelated to operator name.
|
限定符和类型 | 方法和说明 |
---|---|
default java.util.stream.Stream<? extends Scannable> |
actuals()
Return a
Stream navigating the Subscriber
chain (downward). |
static Scannable |
from(java.lang.Object o)
Attempt to cast the Object to a
Scannable . |
default java.util.stream.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 java.lang.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 java.util.stream.Stream<? extends Scannable> |
parents()
Return a
Stream navigating the Subscription
chain (upward). |
default <T> T |
scan(Scannable.Attr<T> key)
内省方法,扫描返回自身组件
Scannable.Attr 的属性值
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 . |
java.lang.Object |
scanUnsafe(Scannable.Attr key)
This method is used internally by components to define their key-value mappings
in a single place.
|
default java.lang.String |
stepName()
|
default java.util.stream.Stream<java.lang.String> |
steps()
List the step names in the chain of
Scannable (including the current element),
in their assembly order. |
default java.util.stream.Stream<Tuple2<java.lang.String,java.lang.String>> |
tags()
|
default java.util.Map<java.lang.String,java.lang.String> |
tagsDeduplicated()
|
static final java.util.regex.Pattern OPERATOR_NAME_UNRELATED_WORDS_PATTERN
static Scannable from(@Nullable java.lang.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 java.util.stream.Stream<? extends Scannable> actuals()
Stream
navigating the Subscriber
chain (downward, current Scannable
not included).default java.util.stream.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 java.lang.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 java.lang.String stepName()
default java.util.stream.Stream<java.lang.String> steps()
Scannable
(including the current element),
in their assembly order. This traverses the chain of Scannable
both upstream
(parents()
) and downstream (actuals()
).
Stream
of stepName()
for each discovered step in the Scannable
chaindefault java.util.stream.Stream<? extends Scannable> parents()
Stream
navigating the Subscription
chain (upward, current Scannable
not included).@Nullable java.lang.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)
Scannable.Attr
的属性值
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.
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 java.util.stream.Stream<Tuple2<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.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
).