-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Do not merge] Support AsyncStream in realtime query #14924
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
base: main
Are you sure you want to change the base?
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback. |
Generated by 🚫 Danger |
let stream = query.asyncThrowingStream() | ||
var iterator = stream.makeAsyncIterator() | ||
|
||
let task = Task { |
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.
Is a Task here really needed?
I found doing it without Task and signalStream much easier to read:
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.
No, the task is mainly used for testing the stream behaviour after the stream closed.
await signalStream.first { _ in true } | ||
|
||
// 4. As soon as we receive the signal, we know it's safe to cancel. | ||
task.cancel() |
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.
Is there a way to verify the stream has been closed?
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.
yes, after the stream closed, the listener (iterator) will received nil
98ad95d
to
8c65663
Compare
|
||
// 3. Wrap the asynchronous work in a Task. | ||
let task = Task { | ||
// Use a standard stream that stays open for new events. |
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 comments like this are too much, this is generated by Gemini I think?
Please reduce the number of comments and only leave those that are the key steps of the tests.
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.
Thank you for the feedback on the comments. My intention was to add clarity to the asynchronous test flow, as these can sometimes be less straightforward to follow than synchronous tests. However, I agree that excessive comments can clutter the code and that focusing on the key steps is a better approach for test readability. I will update the comments to be more concise and highlight only the essential parts of the test setup and execution.
No description provided.