-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ClientModel: Pageable abstractions for third-party clients #44026
Conversation
…be replaced in a polling paradigm
…convenience implementation in a way that postpones sending the request
sdk/core/System.ClientModel/src/Convenience/AsyncPageableCollectionOfT.cs
Outdated
Show resolved
Hide resolved
sdk/core/System.ClientModel/src/Convenience/AsyncPageableCollectionOfT.cs
Outdated
Show resolved
Hide resolved
sdk/core/System.ClientModel/tests/Convenience/PageableCollectionTests.cs
Show resolved
Hide resolved
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.
The approach looks reasonable to me.
It's a shame that the sync/async types are different, but it makes sense if we're trying to align how you enumerate to the sync/async version of the operation that was called.
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.
Fixing review; request for changes was unintentional and due to a mis-click.
Overview
System.ClientModel-based client's service methods need to be able to return collections of values from a paged collection, i.e. where subsets of collection elements are returned iteratively over one more calls to the service. TypeSpec is adding pagination support (see overview and microsoft/typespec#705) and in time our generators will generate third-party clients with such service methods from the TypeSpec.
What's in this PR
This PR adds sync and async abstractions for pageable result collections,
PageableCollection<T>
andAsyncPageableCollection<T>
, as well as aResultPage<T>
type that exposes a continuation token and enables enumeration over the results in the page. It also adds a mock client that illustrates standard patterns for implementing these abstractions, as well as tests that illustrate standard usage patterns of the abstractions, e.g. for changing the size of the page requested from the service, and enumerating results using a page's continuation token.