-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[draft] based on PR 43484, put PagingOptions to retriever lambda #43720
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
Changes from all commits
8dc22b5
b7b47b9
1695f0c
e82c281
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,22 +50,23 @@ public String getNextLink() { | |
| } | ||
|
|
||
| private PagedIterable<TodoItem> list() { | ||
| return new PagedIterable<>(() -> listSinglePage(), nextLink -> listNextSinglePage(nextLink)); | ||
| return new PagedIterable<>((context) -> listSinglePage(context), | ||
| (context, nextLink) -> listNextSinglePage(context, nextLink)); | ||
| } | ||
|
|
||
| private PagedResponse<TodoItem> listSinglePage() { | ||
| Response<TodoPage> res = listSync(); | ||
| private PagedResponse<TodoItem> listSinglePage(PagingOptions pagingOptions) { | ||
| Response<TodoPage> res = listSync(pagingOptions); | ||
| return new PagedResponse<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getBody(), | ||
| res.getValue().getItems(), res.getValue().getNextLink()); | ||
| } | ||
|
|
||
| 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); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, the code would fork in |
||
| 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")); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code here should set the value of |
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
nextLinkorcontinuationToken).It does not handle client-side pageable (i.e. via incremental on
pageIndexorindex).Handling of client-side pageable would require we get the
PagingOptionsof the prior request (in additional to thisPagedResponse), and update it for next page.