Skip to content

paging vs infinite API's - Cloud Storage, but more broadly applicable... #1798

Description

@lesv

In looking at the cloud storage API's, they are really a mapping of our internal protobuf apis to a client surface rather than going with what we had hoped to be the more natural view.

For example we show the following for list:

 String bucketName = "my_unique_bucket";
 String directory = "my_directory/";
 Page<Blob> blobs = storage.list(bucketName, BlobListOption.currentDirectory(),
     BlobListOption.prefix(directory));
 Iterator<Blob> blobIterator = blobs.iterateAll();
 while (blobIterator.hasNext()) {
   Blob blob = blobIterator.next();
   // do something with the blob
 }

In actuality the usage is more like:

 String bucketName = "my_unique_bucket";
 String directory = "my_directory/";
 Page<Blob> blobs = storage.list(bucketName, BlobListOption.currentDirectory(),
     BlobListOption.prefix(directory));
 do {
    Iterator<Blob> blobIterator = blobs.iterateAll();
    while (blobIterator.hasNext()) {
      Blob blob = blobIterator.next();
      // do something with the blob
    }
    blobs = blobs.getNextPage();
  } while ( blobs != null);

In a sense there are cases where it makes sense to use paging, such as doing so in a web app, but there are also many cases where we should hide our complexity from our users and just provide a single blobs iterator.

I don't wish to block GA with this as I don't think it makes sense, but this is something we should fix in the autogenerated libraries. Developers should be able to choose between a paged api, for webapps and the like, and a continuous api (that we can optimize behind the scenes).

@anthmgoogle FYI
@waprin FYI
@jabubake FYI
@garrettjonesgoogle
@jgeewax FYI

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.triaged for GAtype: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions