Skip to content

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

@jherman4

Description

@jherman4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions