Skip to content

Conversation

@ozangunalp
Copy link
Collaborator

Introduces a new pauseDemand() operator that allows pausing and resuming request propagation in reactive streams.

First used in Reactive Messaging pausable channels, this implementation also handles buffering already requested items

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 88.53503% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.06%. Comparing base (556bc46) to head (e5ff7cf).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
...e/mutiny/operators/multi/MultiDemandPausingOp.java 84.54% 7 Missing and 10 partials ⚠️
...tation/src/main/java/io/smallrye/mutiny/Multi.java 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2007      +/-   ##
============================================
- Coverage     89.11%   89.06%   -0.05%     
- Complexity     3068     3101      +33     
============================================
  Files           409      412       +3     
  Lines         13099    13256     +157     
  Branches       1652     1679      +27     
============================================
+ Hits          11673    11807     +134     
- Misses          808      818      +10     
- Partials        618      631      +13     
Files with missing lines Coverage Δ
.../io/smallrye/mutiny/groups/MultiDemandPausing.java 100.00% <100.00%> (ø)
...va/io/smallrye/mutiny/operators/AbstractMulti.java 100.00% <100.00%> (ø)
.../io/smallrye/mutiny/subscription/DemandPauser.java 100.00% <100.00%> (ø)
...tation/src/main/java/io/smallrye/mutiny/Multi.java 89.47% <0.00%> (-4.98%) ⬇️
...e/mutiny/operators/multi/MultiDemandPausingOp.java 84.54% <84.54%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@jponge jponge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an excellent contribution @ozangunalp 👏

See my comments, plus:

  • the MultiDemandPausingTest recorded in the Git tree has some minor reformat being applied at compilation time
  • I don't expect this operator to be any Reactive Streams compliant, so we should document this both in the guide and in the Javadocs.

@jponge jponge added this to the 3.1.0 milestone Nov 20, 2025
@jponge jponge added the enhancement New feature or request label Nov 20, 2025
@ozangunalp
Copy link
Collaborator Author

@jponge I am not sure about the Reactive Streams compliance of this operator. Sure, it can drop some items if it is intentional, but it doesn't emit more than what was requested from downstream.

@jponge
Copy link
Member

jponge commented Nov 20, 2025

That's interesting. I suppose that it won't pass the TCK when paused, but it should pass the TCK when it is not.

We should check this then 😇

@ozangunalp
Copy link
Collaborator Author

That's interesting. I suppose that it won't pass the TCK when paused, but it should pass the TCK when it is not.

I pushed a TCK test with pause/resume at every received item.

Copy link
Member

@jponge jponge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's finish the TCK discussion, then the rest of the PR is excellent!

Comment on lines 10 to 32
public Flow.Publisher<Long> createFlowPublisher(long elements) {
DemandPauser pauser = new DemandPauser();
return upstream(elements).pauseDemand().using(pauser)
.invoke(pauser::pause)
.invoke(pauser::resume);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is different from passing the TCK to the upstream, since we pause then resume on the same call stack.

I think we should have this, or just have the operator as a pass-through, but if we have a TCK test where we pause for longer periods of time then I anticipate the TCK will complain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this only verifies that a simple pause/resume doesn't break the TCK.

Another test is needed with an async consumption and an operator with prefetch.

I think if the operator is eventually resumed inside the test it should pass the TCK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jponge I pushed a small update to the operator and the TCK test.
It now passes the TCK without a pass-through stream as long as the stream is not left in a paused state.
Specifically, it now handles the completion case better.

I also added a note to the javadoc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let's re-run the CI :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@jponge jponge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

Let's just not merge now, I might have a fix or two to stage in a patch release over the next 2 weeks.

@jponge
Copy link
Member

jponge commented Nov 27, 2025

I'm doing another patch release, then this will go to main

@jponge jponge merged commit cc5a609 into smallrye:main Nov 27, 2025
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants