-
Notifications
You must be signed in to change notification settings - Fork 907
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
refactor(experimental): a transport that coalesces multiple subscriptions behind a single subscription #1623
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @steveluscher and the rest of your teammates on Graphite |
f541747
to
7b7d498
Compare
a95a4f6
to
b5ebb78
Compare
7b7d498
to
9df9187
Compare
b5ebb78
to
f68a7a1
Compare
OK! This is all fixed up, and I fixed a ton of bugs with the socket transport along the way. This is ready to review! |
@@ -55,66 +52,3 @@ describe('getSolanaRpcPayloadDeduplicationKey', () => { | |||
); | |||
}); | |||
}); | |||
|
|||
describe('getSolanaRpcSubscriptionPayloadDeduplicationKey', () => { |
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.
Didn't end up needing this stuff.
try { | ||
const iterator = iterable[Symbol.asyncIterator](); | ||
while (true) { | ||
const iteratorResult = await Promise.race([iterator.next(), abortPromise]); |
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.
This whole thing is mega intense, but it all boils down to this.
- Create me a new iterable distinct from all the other ones that share this subscription.
- Make it so that each one is abortable separately.
- Every pass through the iterator, race the iterator and the abort promise; If the user aborts the subscription, it will return right away without waiting for the next message from the subscription.
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.
Thanks, this was a help actually 😅
9df9187
to
61bc3ba
Compare
f68a7a1
to
e2f215f
Compare
61bc3ba
to
ccfbd70
Compare
e2f215f
to
256e002
Compare
ccfbd70
to
7c09215
Compare
256e002
to
c80a372
Compare
7c09215
to
b072aae
Compare
c80a372
to
0fc0266
Compare
b072aae
to
ec57cab
Compare
0fc0266
to
39de3f2
Compare
ec57cab
to
38ab0c7
Compare
39de3f2
to
c913f59
Compare
38ab0c7
to
31a626e
Compare
c913f59
to
6ccb70f
Compare
31a626e
to
d6d8690
Compare
6ccb70f
to
e2bdaf6
Compare
2e69790
to
8698f76
Compare
e2bdaf6
to
64f33e9
Compare
…ions behind a single subscription
64f33e9
to
bd8d5b4
Compare
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.
try { | ||
const iterator = iterable[Symbol.asyncIterator](); | ||
while (true) { | ||
const iteratorResult = await Promise.race([iterator.next(), abortPromise]); |
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.
Thanks, this was a help actually 😅
Merge Activity
|
🎉 This PR is included in version 1.78.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
Summary
This is a transport that, given two identical subscription requests, will issue the subscription request the first time only, and return a the cached iterator for that request each subsequent time, finally tearing the subscription down when the last consumer aborts.
This means that if you
slotSubscribe
from 10 places in your app, those will only ever produce one subscription over the RPC and will fan the notifications out to the callers.Test Plan