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

[draft] a simple PagedIterable / PagedResponse #43484

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

weidongxu-microsoft
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft commented Dec 19, 2024

design https://gist.github.com/srnagar/e9373153593920dcf1977c928c59e988

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

*
* @param <T> The type of items in the page.
*/
public final class PagedResponse<T> implements Response<List<T>> {
Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For azure-core, the PagedResponse is an interface. The implementation is in PagedResponseBase. Should we do the same for clientcore?

In such case, we can even generate the implementation class in emitter (so clientcore does not need to have the PagedResponseBase class).

Comment on lines +198 to +204
private void receivePage(AtomicBoolean receivedPages, PagedResponse<T> page) {
receivedPages.set(true);
addPage(page);

continuationToken = page.getNextLink();
this.done = continuationToken == null || continuationToken.isEmpty();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The receivePage (and related var) would be different, if server support both continuationToken and nextLink.

SDK likely would only provide one pageRetriever with either of the approach. It may also provide a e.g. continuationTokenRetriever to specify whether to call getNextLink or getContinuationToken.

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

io.clientcore:core

@weidongxu-microsoft weidongxu-microsoft changed the title [draft] add a simple PagedIterable / PagedResponse [draft] a simple PagedIterable / PagedResponse Dec 19, 2024
Copy link
Contributor

@XiaofeiCao XiaofeiCao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for nextLink.

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.

3 participants