-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature Request: Queries that return IAsyncEnumerable To Iterate Through Cursors #290
Comments
My completely untested attempt in my layer wrapping the Cognite SDK: public static async IAsyncEnumerable<TResult> AsAsyncEnumerable<TResult, TQuery>(
Func<TQuery, CancellationToken, Task<ItemsWithCursor<TResult>>> listAsync,
TQuery query,
[EnumeratorCancellation] CancellationToken token)
where TQuery : CursorQueryBase
{
var itemsWithCursor = await listAsync(query, token);
foreach (var item in itemsWithCursor.Items)
{
yield return item;
}
while (!string.IsNullOrEmpty(itemsWithCursor.NextCursor))
{
query.Cursor = itemsWithCursor.NextCursor;
itemsWithCursor = await listAsync(query, token);
foreach (var item in itemsWithCursor.Items)
{
yield return item;
}
}
}
public IAsyncEnumerable<TimeSeries> ListAllAsync(TimeSeriesQuery query, CancellationToken token = default)
{
return AsAsyncEnumerable(ListAsync, query, token);
} Feel free to sprinkle in your own F#/Oryx magic. |
Thanks for the tag, @polomani. Can you give a bit more detail around what would be expected from a PR from the community? Does the implementation need to follow the current pattern of being written in Oryx with F# and having a thin C# wrapper around it or would we be good with a C#-only implementation in this case? |
@bbrandt I assume your use-case requires C#? In that case, feel free to make a pure c# implementation. |
Please provide either an extension method to convert
ItemsWithCursor<T>
to anIAsyncEnumerable<T>
for any method or another set of methods for each query returning a cursor such asThe text was updated successfully, but these errors were encountered: