A Scannable component exposes state in a non strictly memory consistent way and results should be understood as best-effort hint of the underlying state. This is useful to retro-engineer a component graph such as a flux operator chain via Stream queries from #actuals(), {@link #paren
| 52 | * @author Stephane Maldini |
| 53 | */ |
| 54 | @FunctionalInterface |
| 55 | public interface Scannable { |
| 56 | |
| 57 | /** |
| 58 | * The pattern for matching words unrelated to operator name. |
| 59 | * Used to strip an operator name of various prefixes and suffixes. |
| 60 | */ |
| 61 | Pattern OPERATOR_NAME_UNRELATED_WORDS_PATTERN = |
| 62 | Pattern.compile("Parallel|Flux|Mono|Publisher|Subscriber|Fuseable|Operator|Conditional"); |
| 63 | |
| 64 | /** |
| 65 | * Base class for {@link Scannable} attributes, which all can define a meaningful |
| 66 | * default. |
| 67 | * |
| 68 | * @param <T> the type of data associated with an attribute |
| 69 | */ |
| 70 | class Attr<T> { |
| 71 | |
| 72 | /* IMPLEMENTATION NOTE |
| 73 | Note that some attributes define a object-to-T converter, which means their |
| 74 | private {@link #tryConvert(Object)} method can safely be used by |
| 75 | {@link Scannable#scan(Attr)}, making them resilient to class cast exceptions. |
| 76 | */ |
| 77 | |
| 78 | /** |
| 79 | * The direct dependent component downstream reference if any. Operators in |
| 80 | * Flux/Mono for instance delegate to a target Subscriber, which is going to be |
| 81 | * the actual chain navigated with this reference key. Subscribers are not always |
| 82 | * {@link Scannable}, but this attribute will convert these raw results to an |
| 83 | * {@link Scannable#isScanAvailable() unavailable scan} object in this case. |
| 84 | * <p> |
| 85 | * A reference chain downstream can be navigated via {@link Scannable#actuals()}. |
| 86 | */ |
| 87 | public static final Attr<Scannable> ACTUAL = new Attr<>(null, |
| 88 | Scannable::from); |
| 89 | |
| 90 | /** |
| 91 | * Indicate that for some purposes a {@link Scannable} should be used as additional |
| 92 | * source of information about a contiguous {@link Scannable} in the chain. |
| 93 | * <p> |
| 94 | * For example {@link Scannable#steps()} uses this to collate the |
| 95 | * {@link Scannable#stepName() stepName} of an assembly trace to its |
| 96 | * wrapped operator (the one before it in the assembly chain). |
| 97 | */ |
| 98 | public static final Attr<Boolean> ACTUAL_METADATA = new Attr<>(false); |
| 99 | |
| 100 | /** |
| 101 | * A {@link Integer} attribute implemented by components with a backlog |
| 102 | * capacity. It will expose current queue size or similar related to |
| 103 | * user-provided held data. Note that some operators and processors CAN keep |
| 104 | * a backlog larger than {@code Integer.MAX_VALUE}, in which case |
| 105 | * the {@link Attr#LARGE_BUFFERED Attr} {@literal LARGE_BUFFERED} |
| 106 | * should be used instead. Such operators will attempt to serve a BUFFERED |
| 107 | * query but will return {@link Integer#MIN_VALUE} when actual buffer size is |
| 108 | * oversized for int. |
| 109 | */ |
| 110 | public static final Attr<Integer> BUFFERED = new Attr<>(0); |
| 111 |
no outgoing calls
no test coverage detected
searching dependent graphs…