DEV Community

Salad Lam
Salad Lam

Posted on

Project Reactor: About Scannable interface

Simple to say, reactor.core.Scannable interface is for accessing internal attributes of flux instance for debugging purpose. Following is an example

Flux<Integer> f1 = Flux.just(1, 2, 3, 4);
Scannable s1 = Scannable.from(f1);
LOGGER.info("BUFFERED={}, RUN_STYLE={}", s1.scan(Scannable.Attr.BUFFERED), s1.scan(Scannable.Attr.RUN_STYLE));
Flux<Integer> f2 = f1.map(x -> x * 2);
Scannable s2 = Scannable.from(f2);
LOGGER.info("RUN_STYLE={}, PREFETCH={}, PARENT={}", s2.scan(Scannable.Attr.RUN_STYLE), s2.scan(Scannable.Attr.PREFETCH), s2.scan(Scannable.Attr.PARENT));
Enter fullscreen mode Exit fullscreen mode

The output is

BUFFERED=4, RUN_STYLE=SYNC
RUN_STYLE=SYNC, PREFETCH=-1, PARENT=FluxArray
Enter fullscreen mode Exit fullscreen mode

About the meaning of attribute please refer to here.

Top comments (0)