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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay