eclipse / microprofile-reactive-streams-operators

Microprofile project
Apache License 2.0
79 stars 33 forks source link

Which to use for inner Publishers: buildRs or buildRs(ReactiveStreamsEngine)? #137

Closed akarnokd closed 3 years ago

akarnokd commented 4 years ago

There are several methods that accept PublisherBuilder-based sources, such as flatMap:

flatMap(Function<? super T, ? extends PublisherBuilder<? extends S>> mapper)

When translating this into a library's appropriate operator expecting an inner Publisher, there are two ways to get that Publisher: using buildRs and buildRs(ReactiveStreamsEngine).

My problem is, since they both return Publisher and Publisher is the interoperation type of Reactive Streams, it is unclear which to use and why given their implications.

buildRs supposedly uses the global or service-located engine, which could be anything. Therefore, the mapper would possibly trigger a very inefficient graph-rebuilding onto an arbitrary runtime representation.

buildRs(ReactiveStreamsEngine) implies the graph should be rebuilt for another representation. If so, is it supposed to be the the engine for the target representation the PublisherBuilder is using?

Consequently, why would I have to rebuild a graph of a 3rd party PublisherBuilder to my current underlying representation when components can talk to each other via Reactive Streams, with whatever underlying implementation they have, just fine?

Emily-Jiang commented 4 years ago

Remove buildRs(ReactiveStreamsEngine) from the PublisherBuilder as this method was added for TCK purpose.

Emily-Jiang commented 3 years ago

My above comment was not quite right. It does has some limited usage. I have added some javadoc to clarify the usage and indicate the preference.