Skip to content

Loadbalancer: closing doesn't subscribe to the underlying #148

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

Merged
merged 2 commits into from
Jul 15, 2016

Conversation

stevegury
Copy link
Member

_Problem_
Closing the loadbalancer doesn't properly subscribe to the Publishers
returned by the close() methods of the underlying ReactiveSocket.
Thus, the close event is lost at the LoadBalancer level.

_Solution_
Properly subscribe to the close Publishers and propagate the onComplete
events when all ReactiveSocket are closed. (I choose to ignore any exception
that happened during the close, i.e. only propagate 1 onComplete).

***Problem***
Closing the loadbalancer doesn't properly subscribe to the `Publisher`s
returned by the `close()` methods of the underlying `ReactiveSocket`.
Thus, the close event is lost at the LoadBalancer level.

***Solution***
Properly subscribe to the close `Publisher`s and propagate the `onComplete`
events when all `ReactiveSocket` are closed. (I choose to ignore any exception
that happened during the close, i.e. only propagate 1 `onComplete`).
@Override
public void onError(Throwable t) {
if (n.decrementAndGet() == 0) {
subscriber.onComplete();
Copy link

@nickmahilani nickmahilani Jul 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can propagate the onError to the subscriber here?
EDIT: just saw your description, I think would be nice to log the error so we know if there was an exception.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

@nickmahilani
Copy link

one minor comment, LGTM


@Override
public void onComplete() {
if (n.decrementAndGet() == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're doing the same thing in the onComplete and the onError - why not just call onComplete in the onError method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, it makes the code simpler.

@robertroeser robertroeser merged commit b91721d into master Jul 15, 2016
@stevegury stevegury deleted the stevegury/fix-lb-close branch July 15, 2016 22:30
ilayaperumalg pushed a commit to ilayaperumalg/rsocket-java that referenced this pull request Dec 26, 2017
`CONNECTION_CLOSE` error code

As discussed in issue rsocket#59 having an error code to indicate "safe closure" similar to GO_AWAY frame in HTTP/2 will be useful to indicate graceful shutdown as opposed to a fatal erro.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants