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] based on PR 43484, put PagingOptions to retriever lambda #43720

Conversation

weidongxu-microsoft
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft commented Jan 7, 2025

For #43484

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.

@weidongxu-microsoft weidongxu-microsoft changed the title put PagingOptions to retriever lambda [draft] based on PR 43484, put PagingOptions to retriever lambda Jan 7, 2025
private PagedResponse<TodoItem> listNextSinglePage(String nextLink) {
Response<TodoPage> res = listNextSync(nextLink);
private PagedResponse<TodoItem> listNextSinglePage(PagingOptions pagingOptions, String nextLink) {
Response<TodoPage> res = (nextLink == null) ? listSync(pagingOptions) : listNextSync(nextLink);
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, the code would fork in nextLink. If nextLink exists, it would just request that URL; if nextLink not exist, it would call the same API, but with pagingOptions updated (e.g. continuationToken updated from the prior page).

Comment on lines +231 to +234
nextLink = page.getNextLink();
continuationToken = page.getContinuationToken();
this.done = (nextLink == null || nextLink.isEmpty())
&& (continuationToken == null || continuationToken.isEmpty());
Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Jan 7, 2025

Choose a reason for hiding this comment

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

Code here and above only handle the server-driven pageable (i.e. nextLink or continuationToken).

It does not handle client-side pageable (i.e. via incremental on pageIndex or index).

Handling of client-side pageable would require we get the PagingOptions of the prior request (in additional to this PagedResponse), and update it for next page.

return new PagedResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getBody(),
res.getValue().getItems(), res.getValue().getNextLink());
}

private Response<TodoPage> listSync() {
private Response<TodoPage> listSync(PagingOptions pagingOptions) {
// mock request on first page
return new HttpResponse<>(null, 200, null, new TodoPage(List.of(new TodoItem(), new TodoItem()), "nextLink1"));
Copy link
Member Author

@weidongxu-microsoft weidongxu-microsoft Jan 7, 2025

Choose a reason for hiding this comment

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

Code here should set the value of pagingOptions.continuationToken into the proxy API.
(it also means emitter/codegen need to do special handling for continuationToken param, as it should appear on proxy API, but not on client method API)

@weidongxu-microsoft weidongxu-microsoft force-pushed the clientcore-paged_paging-context branch from 1cffdc6 to 1695f0c Compare January 8, 2025 03:17
@weidongxu-microsoft weidongxu-microsoft marked this pull request as ready for review January 9, 2025 02:57
@weidongxu-microsoft weidongxu-microsoft merged commit 74c95f9 into Azure:clientcore-paged Jan 9, 2025
12 of 14 checks passed
@weidongxu-microsoft weidongxu-microsoft deleted the clientcore-paged_paging-context branch January 9, 2025 02:58
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.

1 participant