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

Enumerable query results #37

Merged
merged 10 commits into from
Dec 28, 2021
Merged

Enumerable query results #37

merged 10 commits into from
Dec 28, 2021

Conversation

Zastai
Copy link
Owner

@Zastai Zastai commented Dec 27, 2021

This adds new BrowseAll... and FindAll... methods, which return a new IStreamingQueryResults interface.
That interface includes both IEnumerable and IAsyncEnumerabe, enabling easy bulk processing of browse/search results using foreach or await foreach.

Note: this still uses paged requests "under the hood". This means that items might be missed or returned twice, if the result set changes inbetween calls.

`TInterface` was renamed to `TResults`, because that matches what it is
better (it's the specific implementation of `IPagedQueryResult` being
used, not an interface).

Adjusted documentation.

Reorganized `PagedQueryResults` with regions, separating code that
implements `IPagedQueryResults` from the internals and the protected
elements used by subclasses.
To keep file size down, this is now split further by the type of element
being returned by the methods.
Its implementation (`StreamingQueryResults`) wraps a `PagedQueryResults`
and implements both `IEnumerable` and `IAsyncEnumerable` to iterate over
*all* results in one pass.

This also adds an (internal) `IsActive` property to `IPagedQueryResults`
to indicate whether or not any requests have been executed. This is
needed by `StreamingQueryResults` to determine whether it should start
by executing `Next[Async]()`.
Instead of documenting their return value as "An asynchronous operation
returning ...", they now document the actual return value, ignoring the
presence of the `Task`.
To keep file size down, this is now split further by the type of element
being returned by the methods.
These are like the existing `FindXxx` and `FindXxxAsync` method but they
return an `IStreamingQueryResults` instead, allowing for easy bulk
processing.

This also leverages <inheritdoc> to significantly reduce duplication of
doc comments.
These now use <inheritdoc> to copy the documentation from their async
counterparts.
These are like the existing `BrowseXxx` and `BrowseXxxAsync` methods but
they return an `IStreamingQueryResults` instead, allowing for easy bulk
processing.

This also adds a few overloads of `Query.BuildExtraText`.
@Zastai Zastai added the feature A new feature or API was added (requires a bump of the minor version) label Dec 27, 2021
This enables users to call the non-stream browse/search methods (to
find out how many results there are in total, for example), and then
still easily enumerate the full result set.
@Zastai
Copy link
Owner Author

Zastai commented Dec 27, 2021

Keeping this open a bit to allow comments.

I'm also preparing a follow-up PR that will make all async methods cancelable (without adding more overloads, so this will break binary (but not source) compatibility and become a 5.0.0 release).

@Zastai Zastai merged commit 38873c0 into main Dec 28, 2021
@Zastai Zastai deleted the enumerable-query-results branch December 28, 2021 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or API was added (requires a bump of the minor version)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant