-
Notifications
You must be signed in to change notification settings - Fork 224
Add FromChannelWithContext() #124
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: v4
Are you sure you want to change the base?
Conversation
from.go
Outdated
|
||
// FromChannelWithTimeout initializes a linq query with a passed channel, | ||
// but stops iterating either when the channel is closed or when the timeout elapses. | ||
func FromChannelWithTimeout[T any](source <-chan T, timeout time.Duration) Query { |
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.
Why don't we just do ctx instead? That way we support any form of cancellation not just time.
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 added FromChannelWithContext
method and kept FromChannelWithTimeout
for convenience, but I am not sure it is really needed. wdyt?
bd0b09e
to
ae7bc58
Compare
ee46563
to
1e037ec
Compare
1e037ec
to
771eb7c
Compare
I think we should just remove the Timeout one. It's fairly easy to implement given ctx signature is offered on another method. |
Yes, very much agree, had a similar feeling. UPDATE: Though we can slightly change |
I think it's fine to just have the ctx version. Typically if someone has a deadline it applies to the whole thing not when we start iterating. |
resolves #93