-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow easy paging for list operations #895
Copy link
Copy link
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Taking the comment on https://github.com/GoogleCloudPlatform/gcloud-python/pull/889/files#r31042158 over here.
Requiring explicit paging for topics is really ugly, there must be a better way than:
If our concern is "people could make a boatload of requests and they don't realize it", we could always limit this like we do with the recursive deleting in storage?
We can do a bunch of this with the
page_sizeparameter, but that might mean that I have to wait for everything to come back before starting any work, which seems kind of ridiculous.It'd be really nice if that limit and page-size stuff was both there, so it's easy to do things like "I want the first 5000 topics, and I want to pull them from the server in chunks of 50":
To add a bit more context, I'd like to toss out: what if we made all of our list operations return iterators?
The use cases I see here are...
for topic in list_topics())for topic in list_topics(limit=100))for topics in list_topics(): if topic.name == 'foo': break)offset)! (for topic in list_topics(page_token=token, limit=100))The "let's just always return
page, page_token" thing doesn't really make all of those use-cases all that fun... But if we always return iterators, they are all easy.Further, let's say I have a weird case where I just want one page worth of stuff...
list_topics().get_current_page()could return what you want, no?