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

ClientModel: Pageable abstractions for third-party clients #44026

Merged
merged 70 commits into from
May 16, 2024

Conversation

annelo-msft
Copy link
Member

@annelo-msft annelo-msft commented May 14, 2024

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> and AsyncPageableCollection<T>, as well as a ResultPage<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.

…convenience implementation in a way that postpones sending the request
@annelo-msft annelo-msft changed the title ClientModel: third-party pageable types ClientModel: Pageable abstractions for third-party clients May 15, 2024
@annelo-msft annelo-msft marked this pull request as ready for review May 15, 2024 22:16
Copy link
Member

@jsquire jsquire left a 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.

Copy link
Member

@jsquire jsquire left a 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.

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

Successfully merging this pull request may close these issues.

None yet

5 participants