Skip to content
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

Keep session links #147

Merged
merged 9 commits into from
Aug 7, 2015
Merged

Keep session links #147

merged 9 commits into from
Aug 7, 2015

Conversation

noodlefrenzy
Copy link
Owner

I was closer to right than you were - it was more than just not setting session to null.

  • Remove reattach logic from client
  • Stop setting session to null on disconnect
  • Stop session from clearing link state on detach
  • Add reattach policies for link, akin to client's reconnect policies
  • Ensure link doesn't attempt reattach if it's detached by our side
  • Add a "forceDetach" to force existing links into a detached state if the session/connection is killed

var detachPromise = new Promise(function(resolve, reject) {
var onError = function(err) { reject(err); };
self.once(Link.ErrorReceived, onError);
self.once(Link.Detached, function(info) {
self.removeListener(Link.ErrorReceived, onError);
self.session._removeLink(self);
Copy link
Collaborator

Choose a reason for hiding this comment

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

something feels wrong about this, shouldn't the session listen to Link.Detach events itself and remove the links from there? I guess this is better stated as: why is Session's internal state something Link cares about?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I struggled with this. Basically a session should only remove the link when it's given up on itself (either because we called detach or because it's run out of retries). The link is the one who knows when it's given up - and that doesn't coincide with a Detach event. So either the session needs to interrogate the link on whether it might still be trying to attach, or the link needs to tell the session it's done. I chose the latter, but I can see why the former makes sense given our separation of concerns - I can do that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless I'm reading this incorrectly the code as it stands still removes the link every Link.Detach though right? Nothing different than the existing Link.Detach in Session

Copy link
Owner Author

Choose a reason for hiding this comment

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

No, it removes it only when the detach comes from our side. When the detach is instigated by the server, it leaves it alone.

self.emit(AMQPClient.ErrorReceived, e);
});
}

self._session.on(Session.Mapped, function(s) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to unregister this listener (existing bug)

noodlefrenzy added a commit that referenced this pull request Aug 7, 2015
@noodlefrenzy noodlefrenzy merged commit c4e3e8c into master Aug 7, 2015
@noodlefrenzy noodlefrenzy deleted the keep-session-links branch August 7, 2015 01:07
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.

None yet

2 participants