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

Update PagingIterator #737

Merged
merged 13 commits into from
Apr 28, 2021
Merged

Update PagingIterator #737

merged 13 commits into from
Apr 28, 2021

Conversation

jlawton
Copy link
Contributor

@jlawton jlawton commented Oct 22, 2020

Issue 🔗

PagingIterator is a pain to use when writing apps.

Goals ⚽

  • Change PagingIterator.next to return pages, which will simplify usage for most apps.
  • Return PagingIterator directly from the API, as it now requests the first page itself.

Implementation Details 🚧

  • Removed the buffer internal to the iterator and simplified the logic.
  • There are no longer 2 places where failure can be reported. Construction no longer fails.
  • There are no longer 2 places which parse pages. Construction doesn't parse a page.
  • Hide nextPage from consumers, though there may be a good reason to expose something like it.

Testing Details 🔍

Tests currently fail to build on my machine, but that is true on master, so it is not due to my changes.

@jlawton jlawton requested a review from sujaygarlanka October 22, 2020 09:05
@jlawton
Copy link
Contributor Author

jlawton commented Oct 22, 2020

@sujaygarlanka Interested in feedback on this alternative API.

@jlawton jlawton changed the title Replace PagingIterator Update PagingIterator Oct 22, 2020
@theli
Copy link

theli commented Feb 19, 2021

I have felt recently how painful it is to use PagingIterator in listItems call and will take another route by calling API endpoint directly.
It looks like there has not been any progress since October on this issue. Is it still in plans to do?

@jlawton
Copy link
Contributor Author

jlawton commented Feb 19, 2021

@theli I made this contribution as a proposal. Is this an interface you'd be happy with? I know the team wouldn't want to have repeated incompatible changes, and I can push for a decision on this especially if it meets your use case as well as mine.

@theli
Copy link

theli commented Feb 23, 2021

I have not reviewed thoroughly the pull request but it looks like it fixes biggest pain point which is async execution of .next method of the PagingIterator.
Another complexity was not having the number of items returned makes it difficult to know when iterator has reached the end of list. It seems like the .failure result was supposed to serve the purpose to indicate end of list, however it works only when there is one page of results returned by the API (enforced by "limit" request param). When API response contains marker to nextpage results, there is no .failure.

@swfree swfree force-pushed the AsyncPagesIterator branch from 9123b22 to 205e362 Compare April 27, 2021 23:32
@swfree swfree merged commit 0ad4d08 into main Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants