-
Notifications
You must be signed in to change notification settings - Fork 56
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
feat(session): add support for multiple sessions per client #332
Conversation
72715a8
to
6dfc2bb
Compare
I also pulled in the change from #330 for now so that I can get useful information from the Travis CI build. That change looks good to me and I think it's worth merging in before this goes in. |
9d4210f
to
94f9f91
Compare
Review status: 0 of 10 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. lib/policies/policy.js, line 127 at r1 (raw file):
I'm not wild about calling this Comments from Reviewable |
5edee8f
to
0efd6b1
Compare
0efd6b1
to
4baedbf
Compare
I decided to remove the |
b57de35
to
75e080f
Compare
lib/amqp_client.js
Outdated
resolve(); | ||
}); | ||
|
||
self._session.begin(self._session.policy || self.policy.session); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._session.policy || self.policy.session [](start = 30, length = 43)
if these 2 are the same, no problem. if the existing session doesn't have a policy object, apply the configured one. i get that part - but what if self._session.policy is set to something that is incompatible with self.policy.session (which i assume is the desirable policy) ? should these objects be merged instead ? or why keep the existing policy object at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright the tricky part here is that the policy isn't applied at creation time, but when begin()
is called. therefore, we need to provide the policy each time we start the session again (or it gets cleared out).
for the session created with the client, the policy is never specified directly by the user so i'm fine with doing a merge if we want. the user-created sessions are trickier because they can be specified independently and should supersede that of the client. in those cases we really only want to apply the client's policy if we don't have one (which should never happen but i've been caught by those assumptions too many times to not put in the check).
sound reasonable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha I see. the philosophy of policies as i understand it though is that they are merged and what is passed around are policy overrides - so starting with the client policy and then merging/overriding with the session policy would feel like the natural thing to do. but i defer to your judgement.
In reply to: 163131314 [](ancestors = 163131314)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it's reasonable to do the merge on the built-in one (this line). the user one is weird because the begin()
here is a hidden operation. the policy for the session is specified separately so i don't want to override it if it's already there. i'll add a comment to that one
|
||
if (promises.length > 0) { | ||
Promise.all(promises).then(function() { | ||
self.emit('connected'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.emit('connected'); [](start = 10, length = 23)
unrelated but puzzling nonetheless to me: why would the "connected" state of the client be attached to sessions rather than connection or links?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this one is an artifact of how the Promise-based design works. it's trying to make sure things are in a usable state when the promise returns. since the session is baked into the connection by the library, that means both the connection and the session have to be ready. i considered making it lazy, but didn't know that i'd be able to get away with it without some subtle breaking changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i did make it lazy. the problem is reconnect because the session is already there
test/unit/test_session.js
Outdated
@@ -22,7 +22,7 @@ var test = { | |||
connect: { options: { containerId: 'test' } }, | |||
senderLink: { attach: { name: 'sender' } }, | |||
receiverLink: { attach: { name: 'receiver' } } | |||
}, DefaultPolicy) | |||
}, DefaultPolicy), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, [](start = 19, length = 1)
typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably had something else and took it out. good catch
reestablish? the spec talks about establishing and ending sessions In reply to: 328216141 [](ancestors = 328216141) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i like that. reestablish sounds better to me than restart Comments from Reviewable |
75e080f
to
8068045
Compare
lib/amqp_client.js, line 176 at r2 (raw file): Previously, princjef (Jeff Principe) wrote…
Done. Comments from Reviewable |
test/unit/test_session.js, line 25 at r2 (raw file): Previously, princjef (Jeff Principe) wrote…
Done. Comments from Reviewable |
Addresses #331 by adding the ability to create multiple sessions on the same client/connection and providing policy options for reestablishing the session on end. This feature set is designed to better align the capabilities of amqp10 with the session pattern supported by Azure Service Bus and bring the retry logic inline with what is used for reattach and reconnect.
Features
createSession()
inAMQPClient
to create user sessionscreateSender()
,createSenderStream()
,createReceiver()
,createReceiverStream()
restart
policy option for reestablishing the session after it is endedTests
createSession()
createSender()
,createSenderStream()
,createReceiver()
,createReceiverStream()
restart
Please take a look and let me know what you think of the change. I'm open to changing the design/approach if people have other thoughts.
This change is