[JAVA-3398] Consider Publisher<Void> instead of Publisher<Success> Created: 17/Jul/17 Updated: 28/Oct/23 Resolved: 08/Nov/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Reactive Streams |
| Affects Version/s: | None |
| Fix Version/s: | 4.0.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Mark Paluch | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Major Change | ||||||||
| Description |
|
MongoDB driver returns Publisher<Success> for operations that do not return a value and which would be represented with void in an imperative API. Reactive API's are inherently event-oriented (onNext|onComplete|onError signals) and do not require emission of a placeholder data element to signal successful completion. A successful termination without emitting an element would be the idiomatic approach for a Reactive Streams API. Each composition library has its own strategy how to represent the absence of elements/completion:
It would be great if a future version of the Reactive Streams driver would adapt to Publisher<Void>. Reference:
|
| Comments |
| Comment by Githook User [ 15/Jan/20 ] |
|
Author: {'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}Message: Publisher<Success> => Publisher<Void> Removed the Success enum to represent a successful operation. Idioms Removed the Scala type alias of Completed to Void. This brings the
|
| Comment by Ross Lawley [ 23/Oct/19 ] |
| Comment by Jeffrey Yemin [ 04/Feb/19 ] |
|
Consider for when we merge Reactive Streams into Java Driver 4.0. |
| Comment by Mark Paluch [ 17/Jul/17 ] |
|
Hey ross.lawley, The request wasn't intended for a minor version increment (1.x version) but rather a major release. Indeed, your driver was created in a time with high uncertainty about the ideal patterns. Emission of a null value is not allowed by the Reactive Streams spec so no one would expect a null value to be emitted. RxJava 2 has a rich type-system that isn't entirely based on the Reactive Streams spec, only Flowable is a Publisher. |
| Comment by Ross Lawley [ 17/Jul/17 ] |
|
Hi mp911de, Thanks for the ticket. Unfortunately, this would be an API break and would require a major release. Back when the reactive streams API was still in beta, there wasn't a clear consensus on what pattern should be used for a successful operation. If I recall correctly, Publisher<Void> was explicitly frowned upon at the time; as results couldn't be null it was deemed invalid. It seems more patterns have come from usage overtime and a wider consensus has evolved, and two new Publisher types have evolved: Completable and Single Publishers. Essentially, the Publisher<Success> is comparable with the differing Completable strategies and achieve the same aim. Ross |