From e0a1ccb64a637673195804513902cba6b1d4e97c Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Mon, 31 Oct 2016 16:36:17 +0000 Subject: Update dependencies --- vendor/cloud.google.com/go/storage/bucket.go | 89 ++++++++++------------------ 1 file changed, 32 insertions(+), 57 deletions(-) (limited to 'vendor/cloud.google.com/go/storage/bucket.go') diff --git a/vendor/cloud.google.com/go/storage/bucket.go b/vendor/cloud.google.com/go/storage/bucket.go index 0875f7d..a2be0f4 100644 --- a/vendor/cloud.google.com/go/storage/bucket.go +++ b/vendor/cloud.google.com/go/storage/bucket.go @@ -35,14 +35,13 @@ func (b *BucketHandle) Create(ctx context.Context, projectID string, attrs *Buck } bkt.Name = b.name req := b.c.raw.Buckets.Insert(projectID, bkt) - _, err := req.Context(ctx).Do() - return err + return runWithRetry(ctx, func() error { _, err := req.Context(ctx).Do(); return err }) } // Delete deletes the Bucket. func (b *BucketHandle) Delete(ctx context.Context) error { req := b.c.raw.Buckets.Delete(b.name) - return req.Context(ctx).Do() + return runWithRetry(ctx, func() error { return req.Context(ctx).Do() }) } // ACL returns an ACLHandle, which provides access to the bucket's access control list. @@ -75,12 +74,18 @@ func (b *BucketHandle) Object(name string) *ObjectHandle { bucket: b.name, object: name, }, + gen: -1, } } // Attrs returns the metadata for the bucket. func (b *BucketHandle) Attrs(ctx context.Context) (*BucketAttrs, error) { - resp, err := b.c.raw.Buckets.Get(b.name).Projection("full").Context(ctx).Do() + var resp *raw.Bucket + var err error + err = runWithRetry(ctx, func() error { + resp, err = b.c.raw.Buckets.Get(b.name).Projection("full").Context(ctx).Do() + return err + }) if e, ok := err.(*googleapi.Error); ok && e.Code == http.StatusNotFound { return nil, ErrBucketNotExist } @@ -110,8 +115,11 @@ type BucketAttrs struct { // StorageClass is the storage class of the bucket. This defines // how objects in the bucket are stored and determines the SLA - // and the cost of storage. Typical values are "STANDARD" and - // "DURABLE_REDUCED_AVAILABILITY". Defaults to "STANDARD". + // and the cost of storage. Typical values are "MULTI_REGIONAL", + // "REGIONAL", "NEARLINE", "COLDLINE", "STANDARD" and + // "DURABLE_REDUCED_AVAILABILITY". Defaults to "STANDARD", which + // is equivalent to "MULTI_REGIONAL" or "REGIONAL" depending on + // the bucket's location settings. StorageClass string // Created is the creation time of the bucket. @@ -175,47 +183,6 @@ func (b *BucketAttrs) toRawBucket() *raw.Bucket { } } -// ObjectList represents a list of objects returned from a bucket List call. -type ObjectList struct { - // Results represent a list of object results. - Results []*ObjectAttrs - - // Next is the continuation query to retrieve more - // results with the same filtering criteria. If there - // are no more results to retrieve, it is nil. - Next *Query - - // Prefixes represents prefixes of objects - // matching-but-not-listed up to and including - // the requested delimiter. - Prefixes []string -} - -// List lists objects from the bucket. You can specify a query -// to filter the results. If q is nil, no filtering is applied. -// -// Deprecated. Use BucketHandle.Objects instead. -func (b *BucketHandle) List(ctx context.Context, q *Query) (*ObjectList, error) { - it := b.Objects(ctx, q) - nextToken, err := it.fetch(it.pageInfo.MaxSize, it.pageInfo.Token) - if err != nil { - return nil, err - } - list := &ObjectList{} - for _, item := range it.items { - if item.Prefix != "" { - list.Prefixes = append(list.Prefixes, item.Prefix) - } else { - list.Results = append(list.Results, item) - } - } - if nextToken != "" { - it.query.Cursor = nextToken - list.Next = &it.query - } - return list, nil -} - // Objects returns an iterator over the objects in the bucket that match the Query q. // If q is nil, no filtering is done. func (b *BucketHandle) Objects(ctx context.Context, q *Query) *ObjectIterator { @@ -229,8 +196,6 @@ func (b *BucketHandle) Objects(ctx context.Context, q *Query) *ObjectIterator { func() interface{} { b := it.items; it.items = nil; return b }) if q != nil { it.query = *q - it.pageInfo.MaxSize = q.MaxResults - it.pageInfo.Token = q.Cursor } return it } @@ -248,9 +213,9 @@ type ObjectIterator struct { // PageInfo supports pagination. See the google.golang.org/api/iterator package for details. func (it *ObjectIterator) PageInfo() *iterator.PageInfo { return it.pageInfo } -// Next returns the next result. Its second return value is Done if there are -// no more results. Once Next returns Done, all subsequent calls will return -// Done. +// Next returns the next result. Its second return value is iterator.Done if +// there are no more results. Once Next returns iterator.Done, all subsequent +// calls will return iterator.Done. // // If Query.Delimiter is non-empty, some of the ObjectAttrs returned by Next will // have a non-empty Prefix field, and a zero value for all other fields. These @@ -274,7 +239,12 @@ func (it *ObjectIterator) fetch(pageSize int, pageToken string) (string, error) if pageSize > 0 { req.MaxResults(int64(pageSize)) } - resp, err := req.Context(it.ctx).Do() + var resp *raw.Objects + var err error + err = runWithRetry(it.ctx, func() error { + resp, err = req.Context(it.ctx).Do() + return err + }) if err != nil { return "", err } @@ -319,9 +289,9 @@ type BucketIterator struct { nextFunc func() error } -// Next returns the next result. Its second return value is Done if there are -// no more results. Once Next returns Done, all subsequent calls will return -// Done. +// Next returns the next result. Its second return value is iterator.Done if +// there are no more results. Once Next returns iterator.Done, all subsequent +// calls will return iterator.Done. func (it *BucketIterator) Next() (*BucketAttrs, error) { if err := it.nextFunc(); err != nil { return nil, err @@ -342,7 +312,12 @@ func (it *BucketIterator) fetch(pageSize int, pageToken string) (string, error) if pageSize > 0 { req.MaxResults(int64(pageSize)) } - resp, err := req.Context(it.ctx).Do() + var resp *raw.Buckets + var err error + err = runWithRetry(it.ctx, func() error { + resp, err = req.Context(it.ctx).Do() + return err + }) if err != nil { return "", err } -- cgit v1.2.3