FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Refactor iterator to separate into HTTP/GAX iterators by dhermes · Pull Request #2617 · googleapis/google-cloud-python · GitHub

Refactor iterator to separate into HTTP/GAX iterators - #2617

Merged
dhermes merged 14 commits into
googleapis:masterfrom
dhermes:pubsub-iterators-refactor
Oct 27, 2016
Merged

Refactor iterator to separate into HTTP/GAX iterators#2617
dhermes merged 14 commits into
googleapis:masterfrom
dhermes:pubsub-iterators-refactor

Conversation

dhermes commented Oct 26, 2016
edited
Loading

Copy link
Copy Markdown
Contributor

NOTE: I'm happy to split this PR into tiny PRs if it makes review easy, though the commits are all pretty compact, so it should be reviewable commit-by-commit.

dhermes added api: pubsub Issues related to the Pub/Sub API. api: core labels Oct 26, 2016
googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 26, 2016
This somewhat of a cart-before-the-horse change, but
is done this way to make the commit easier to understand,
before unifying the two approaches via _next_page().
Also moving the token setting behavior from
HTTPIterator._get_next_page_response() into _next_page().
Also a lint fix for an unimorted member and a unit test fix
adding a page token to allow more paging.

Copy link
Copy Markdown
Contributor

This conceptually LGTM, I'll defer @tseaver for implementation review.

dhermes commented Oct 26, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

@tseaver Can I get an amen?

tseaver left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ouch! Commit-by-comit was a hard row to hoe, especially on the last commit, which blew away so much of what had been done before


class Iterator(object):
class HTTPIterator(object):
"""A generic class for iterating through Cloud JSON APIs list responses.

This comment was marked as spam.

Comment thread core/unit_tests/test_iterator.py Outdated
self.assertIs(iterator.client, client)
self.assertEqual(iterator.max_results, max_results)
self.assertEqual(list(iterator._page_iter), [])
self.assertFalse(iterator._page_increment)

This comment was marked as spam.

page = Page(iterator, items, _item_to_topic)
iterator.next_page_token = page_iter.page_token or None
iterator.num_results += page.num_items
yield page

This comment was marked as spam.

Comment thread core/google/cloud/iterator.py Outdated
except StopIteration:
return None

def _wrap_gax(self, page_iter):

This comment was marked as spam.

response = iterator._get_next_page_response()
self.assertEqual(response['items'], [{'name': key1}, {'name': key2}])
self.assertEqual(iterator.page_number, 1)
self.assertEqual(iterator.next_page_token, token)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

dhermes commented Oct 26, 2016

Copy link
Copy Markdown
Contributor Author

@tseaver Sorry for the bait and switch at the end. It didn't become clear that a _next_page could do all the work until all pieces were moved. I considered rewriting the history but hoped it'd be clear enough, my bad.

dhermes merged commit 5f97bc7 into googleapis:master Oct 27, 2016
dhermes deleted the pubsub-iterators-refactor branch October 27, 2016 16:44
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…ctor

Refactor iterator to separate into HTTP/GAX iterators
parthea pushed a commit that referenced this pull request Nov 24, 2025
Refactor iterator to separate into HTTP/GAX iterators
parthea pushed a commit that referenced this pull request Mar 9, 2026
Refactor iterator to separate into HTTP/GAX iterators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: core api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL