-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
type/enhancementA general enhancementA general enhancement
Description
Question
Is there any built-in Project Reactor operator that can merge / reduce elements automatically when backpressure happens?
Conceptually, I am looking for something like:
<S, C, T> Flux<T> mergeOnBackpressure(Flux<S> source,
Supplier<C> containerSupplier,
BiFunction<C, S, C> merger,
Predicate<C> bufferPredicate,
Function<C, T> mapper,
Consumer<S> onDrop)Meaning:
- When downstream is slower than upstream
- Instead of buffering or dropping,
- Reactor would automatically merge multiple incoming signals into one
- And then emit that merged value when downstream requests next
What I Currently Know
Reactor already provides:
onBackpressureLatest()→ keeps the latest value, effectively a special “merge = overwrite”onBackpressureDrop()→ drops valuesonBackpressureBuffer()→ buffers values
But there is no operator that allows a custom merge/reduce function under backpressure, for example:
- accumulating metrics
- merging state snapshots
- summing counters
- coalescing events
Typical Use Case
A typical pattern I need is:
flux
// when downstream is slow:
// instead of buffering or dropping,
// merge multiple upstream values into one
.mergeOnBackpressure(.......)
.concatMap(this::processAsync); // ordered async processingReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type/enhancementA general enhancementA general enhancement