-
Notifications
You must be signed in to change notification settings - Fork 534
Consumer.getSubscriber? #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When saying “capable of getting this anyways” you imply that each implementation knows about the other in order to interface. Taking an Rx Producer and an Akka Consumer as an example, how would you implement This question and some of the others you raised tell me that the intention of the API might not be entirely clear yet: the Producer/Processor/Consumer types are not meant to be the user-facing API, they are meant to be only those elements of the API which allow interoperability of different implementations of the SPI. In Rx when you get an Observable you know what that is quite precisely. When you get a Producer as per this spec, you don’t know which implementation it has. |
Also note that this is Java (JDK) convention (probably due to the fact that Java's access rules are quite limited (no friend access etc): http://docs.oracle.com/javase/7/docs/api/java/nio/channels/SelectableChannel.html#provider() |
That's exactly my point. The API does not hide the SPI, it just provides accessors to it.
Agreed, and since the purpose is just for interoperability, let's just use When interop between libraries happens it's always going to be explicit bridging between them, so let the types clearly communicate where that happens. How does returning a For example, in Rx we could have something like this: class Observable {
public Publisher toPublisher();
} or class Observable implements Producer<T> {
public void produceTo(Consumer<T> consumer);
public Publisher<T> getPublisher();
} In either case, a user needs to know the The first example above is clear and can't be mistaken. The second one is troublesome because what If I were to pass the RxJava AkkaPublisher.from(RxObservable.toPublisher()).subscribe(anAkkaSubscriber)
// or
RxObservable.toPublisher().subscribe(anAkkaSubscriber) Thus, I don't see how
The JDK doing something a certain way is not necessarily a good reason for us doing the same. Especially the NIO API which is basically unusable by anyone without further abstractions on top of it. As a side note, libraries that have a "zero dependency" policy such as RxJava (and I imagine Netty based on www.netty.io homepage statements?) are not going to become dependent on these types in their core libraries until Java 9 or whatever has these. This means that the RxJava |
Btw stupid but why not: getting rid of getXX and just use plain publisher()/subscriber() ? Sent from my iPhone
|
I guess get* is more java like ? Not that I would dislike removing them ;) -- Am 15. April 2014 bei 19:10:07, Stephane Maldini ([email protected]) schrieb: Btw stupid but why not: getting rid of getXX and just use plain publisher()/subscriber() ? Sent from my iPhone
|
Well these java beans semantics are just outdated, plus getter on an interface looks awkward. I'm just thinking loud, in the end we have in Reactor a few place where a Consumer also implements a subscriber and getSubcriber returns this. Sent from my iPhone
|
I agree with Stephane. We've had this argument internally over whether it's appropriate to have getters and setters declared in interfaces and our general consensus is that, although there's not inherently "wrong" with it, it often indicates a problem with the API. |
@jbrisbin A problem as in "don't have methods that take no parameters and return some value" or a problem as in "don't name that kind of methods getX"? (personally I don't care, it seems to be The Java Way) |
sorry miss click - dat button close just left comment... - |
@smaldini Yeah, it's super nice placement of buttons ;) |
I think we can close this and discuss on the pull request? |
Agree, closing it since I am good at it (anyone can reopen if it feels necessary). |
If
Subscriber
is considered part of the SPI and never intended for use by the user, why is it exposed onConsumer
?In particular, what would be the point of ever retrieving it? There are no methods of use to invoke from a consumer perspective. In fact, if any are invoked they are now altering the data flow.
The javadoc states "This method should only be used by implementations of this API."
Since an implementation would have access to the concrete types and capable of getting this anyways it seems that it should not be on the
Consumer
type where it will confuse and allow incorrect behavior.The text was updated successfully, but these errors were encountered: