-
Notifications
You must be signed in to change notification settings - Fork 22
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
Awaiting async function in async iterator #77
Awaiting async function in async iterator #77
Conversation
George-Payne
commented
Nov 16, 2020
- Allow awaiting within async iterators
- Queue events and pull as needed
- If no events in queue, wait for next event
- Move to seperate SubscriptionItorator and return that in async iteration (for both subscription types)
- Add same test case for persistent subscriptions
- Queue events and pull as needed - If no events in queue, wait for next event - Move to seperate SubscriptionItorator and return that in async iteration (for both subscription types)
Won't using a queue like this run the risk of running out of memory if the stream that is subscribed to is large and the async function takes long? I'm not seeing any backpressure. Would it be possible to access a readable stream from a subscription? |
- allow subscriptions to be paused and resumed - test that events aren't skipped or duplicated when stream is paused and resumed
You're quite right, I've capped the length of the queue to be 10 by pausing and resuming the subscription. |
Looks like the correct way to do this, but I'll need to do more reading before I go about implementing it. I've opened an issue (#78) to track it. |
I'm not sure if the GPRC stream are Node streams as well, but if they are, you may be able to simplify this, since Node readable streams are async iterables/have a |
Dropping by to let you know that this fixed my issue 👍 |
I've moved it over to using streams, need to decide if / how we want to expose the stream directly. It might be that I replace |
🎉 @George-Payne / @hayley-jean Could you publish a new package version? |
@thomastoye Just published |