Open
Description
Use case
Any hot flow of limited size, or unlimited flow that can complete abnormally. Examples:
- A pipeline driven by external source (say, a streaming HTTP request parser producing a number of elements)
- An I/O driven pipeline ("read from here forever and put into this flow... oops, network error")
The Shape of the API
Current Behavior
- There is a
MutableSharedFlow
, but the only operation that communicates data to the consumer isemit()
(per documentation, "SharedFlow
never ends"). It is not possible to communicate neither completion, nor an error. - This behavior is already supported by channels, but they are a different abstraction that can't be reused here without adapters.
Desired Behavior
- Emitter side: add
complete()
anderror(cause)
operations. - Consumer side: no changes, existing abstractions already support this.
Prior Art
Project Reactor Sinks.Many tryEmitComplete(), tryEmitError(error)
Note about "non-example" remark from the issue template
This feature is requested not because it is present in Reactor, but because it is a logical extension of flow behavior. This behavior is already implicitly supported by cold flows (complete()
happens upon the end of the flow originating set, and error()
happens upon throwing an exception from within the flow source), and channels. Having this feature present in the flow will make the behavior uniform across different flow kinds (cold and hot) and make channel adapters behave in a more predictable way.