-
Notifications
You must be signed in to change notification settings - Fork 534
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
Rule §2.12 prevents some optimizations? #290
Comments
Hi @akarnokd, I have no idea how I managed to miss this Issue. I am deeply sorry. I am not 100% sure I understand what you want to achieve, but it is important to remember that the spec applies to generic Publishers, Subscribers, Subscriptions and Processors. If you control the Publisher AND Subscriber implementation, you can in theory do what you want, as long as an arbitrary Subscriber which is given to your Publisher gets the RS spec treatment and vice versa. @reactive-streams/contributors Would be interesting to get your takes on this too. |
The problem arises because I don't control the sources where I want to subscribe the same, thread-safe, If it were only RxJava 2.x+ and Project Reactor 2.5+, I am certain this reuse doesn't cause problems because neither of them cares. That leaves us with Akka-Streams as the major player in the field. |
Hmmm, perhaps I was unclear: you are free to treat implementation that you are sure will be fine with it. The spec applies to generic/arbitrary implementations of the RS interfaces which conform to the spec and TCK. Doesn't that answer your question? |
Type checking as in instanceof seems too specific for at least 2 major implementors. But I'm fine with not solving this immediately, there are other issues that might limit our protocol in general which we need to focus on especially the onErroring on |
We will want to loosen some TCK rules around reference checking at least to avoid us constantly commenting out this rule in the reactor tests. |
@smaldini If your Subscriber instance allows 2:12 to be violated then that is fine. The rule is there to make sure that a Publisher does not assume that an arbitrary Subscriber supports multisubscription. Also, the rule does not require a Publisher to keep track of all Subscribers it has ever Subscribed. :) |
@smaldini I think we should definitely sit down and write down the intents behind the rules, I've been too busy with other stuff but it seems that a lot of progress could be made if we had those in place. What do you think? |
@viktorklang Don't worry mate I am to blame too for the same reasons as you expect :) But it's not a bad timing, we have all endured and matured for a year now we can do these tweaks. The positive outcome is still here, the contract interfaces while simple are a game changer, focused enough. Then it's all about smoothing corner cases and updating the fantastic TCK job @ktoso pushed. It's our duty to all ! |
@smaldini Let's pick it up when you're back! Ping us here :) |
@smaldini Ping |
In early versions of spec, I suggested making re-subscribe a no-op, but there was an objection (I think by @rkuhn) that I don't remember and can't easily find. Even if spec is unchanged, it would be good to find or reconstruct this argument. |
From @akarnokd:
The RS rules are there for generic Subscribers to be valid incarnations of the RS spec. @DougLea @rkuhn If someone can find and reconstruct it, it would be most helpful indeed. |
@viktorklang are Processors considered as "a generic Subscriber" as if 2.12 combines with 4.2:
makes Processor useless. |
Hi Kalin, I'm not sure I follow, could you elaborate what you mean? Cheers, On Sep 18, 2016 11:18, "Kalin Maldzhanski" [email protected] wrote:
|
So as I understand 2.12 re-subscribe is not possible. Processor however routes events from the upstream to its subscribers. In some scenarios upstream Publisher needs to be changed or resubscribed then the processor needs to re-initialize and also all its subscribers. In the case of 4.2 if a Processor chooses to recover from onError signal a natural continuation would be to resubscribe and continue to provide events to its subscribers otherwise it would simply pass on the OnError. As you mentioned anybody can do anything with their subscribers however:
So is the default implementation of Processors considered as generic Subscriber which shall not allow re-subscription? What shall we expect from those? Currently RxJava 2.x Processors and part of Reactor3 ones allow this. Thx! |
Recovery does not necessarily mean to subscribe to another Publisher, it can also mean to just inject some elements of its own and then complete. This is still recovery because it stops the failure from tearing down the (assumed) whole chain of Processors. Another thought is that once a Publisher has failed, why would a Processor subscribe to that same Publisher again? It has failed, after all. It would be more plausible to procure a new Publisher to subscribe to, which is not forbidden AFAICT. |
true. so it is not forbidden to subscribe to another publisher after the current subscription is considered cancelled? This was not that obvious to me. |
I spoke too soon: 2.12 forbids calling onSubscribe again, which expresses that even though different Publishers would be unable to prevent such reuse Subscribers cannot be assumed to be reusable. If you were to write such a Processor that resubscribes itself then that feature would be special to your implementation and not usable by external code that is governed by the spec.
|
Sorry for my slow response rate here, I'm in the middle of a cold; a I think/suspect most of the questions like these could be solved by having On Mon, Sep 19, 2016 at 9:06 AM, Roland Kuhn [email protected]
Cheers, |
Closing. Generic Subscribers cannot be assumed to be reusable: i.e. if all you know is that you have a Subsriber, you cannot, by the spec, be allowed to resubscribe it. |
I'd like to implement a publisher which resubscribes to a source publisher a number of times (unless an error happens in one of those runs). The optimization is to only have a single instance of the mediator
Subscriber
which is always resubscribed (trampolined to prevent SO) to the source when the previous subscription firesonComplete
. However, §2.12 forbids this reuse and if the source enforces this in some way (i.e., storing the current set of subscribers in a thread-safe set and removing the completed one after the call toonComplete
) the repeat can't work.Here is the code of the publisher I'm talking about.
(
SubscriptionArbiter
makes sure any unfulfilled request is re-requested from the Publisher in the next turn.)Therefore, this object equality requirement gives me trouble. Do I interpret §2.12 correctly or rule §2.4 and/or §1.6 actually allows this, i.e., reuse is allowed the moment the publisher is about to call
onError
oronComplete
?(This also affects operators such as
concat
andretry
where the terminal event triggers a new subscription with the same mediatorSubscriber
).The text was updated successfully, but these errors were encountered: