-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[draft] based on PR 43484, put PagingOptions to retriever lambda #43720
Conversation
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); |
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.
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).
nextLink = page.getNextLink(); | ||
continuationToken = page.getContinuationToken(); | ||
this.done = (nextLink == null || nextLink.isEmpty()) | ||
&& (continuationToken == null || continuationToken.isEmpty()); |
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.
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")); |
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.
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)
1cffdc6
to
1695f0c
Compare
74c95f9
into
Azure:clientcore-paged
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:
General Guidelines and Best Practices
Testing Guidelines