Skip to content
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

Any plans to refactor the "Query" and "Lookup" functions to use context instead of a hard timeout? #111

Open
jherman4 opened this issue Oct 31, 2023 · 0 comments

Comments

@jherman4
Copy link

jherman4 commented Oct 31, 2023

Given that results are streaming to a channel, using a context instead of a hard timeout would be more appropriate. Working with a hard timeout within the concurrency model set up in this library somewhat awkward and limiting. For example what if I want to read entries from a channel until I find all of the entries I am looking for and then move on? Currently to do this you either have to:

  1. Choose an overly long timeout and be okay with the goroutine running Query not exiting until potentially long after its task has be fulfilled
  2. Repeat calls to Query with a short timeout in a loop

1 means sacrificing performance and even if its unlikely to be a bottleneck in your applications resource use its still pretty grating to anyone who cares about good design. Whereas 2 feels like over-engineering due to utilizing a clunky API.

Having these functions take a context would allow library users to readily choose whether they want to use the timeout model or logic driven cancellation using well defined and understood patterns from the go standard library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant