Skip to content

Commit

Permalink
feat(storage): json downloads (#7158)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennaEpp committed Feb 15, 2023
1 parent b4d0ff0 commit 574a86c
Show file tree
Hide file tree
Showing 13 changed files with 1,135 additions and 574 deletions.
3 changes: 3 additions & 0 deletions storage/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ The client will use your default application credentials. Clients should be
reused instead of created as needed. The methods of [Client] are safe for
concurrent use by multiple goroutines.
You may configure the client by passing in options from the [google.golang.org/api/option]
package. You may also use options defined in this package, such as [WithJSONReads].
If you only wish to access public data, you can create
an unauthenticated client with
Expand Down
2 changes: 1 addition & 1 deletion storage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
cloud.google.com/go v0.107.0
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/iam v0.8.0
cloud.google.com/go/iam v0.10.0
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions storage/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9
cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs=
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
cloud.google.com/go/iam v0.8.0 h1:E2osAkZzxI/+8pZcxVLcDtAQx/u+hZXVryUaYQ5O0Kk=
cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE=
cloud.google.com/go/iam v0.10.0 h1:fpP/gByFs6US1ma53v7VxhvbJpO2Aapng6wabJ99MuI=
cloud.google.com/go/iam v0.10.0/go.mod h1:nXAECrMt2qHpF6RZUZseteD6QyanL68reN4OXPw0UWM=
cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down
8 changes: 8 additions & 0 deletions storage/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package storage
import (
"context"
"encoding/base64"
"errors"
"fmt"
"io"
"net/url"
Expand Down Expand Up @@ -110,6 +111,11 @@ func newGRPCStorageClient(ctx context.Context, opts ...storageOption) (storageCl
s := initSettings(opts...)
s.clientOption = append(defaultGRPCOptions(), s.clientOption...)

config := newStorageConfig(s.clientOption...)
if config.readAPIWasSet {
return nil, errors.New("storage: GRPC is incompatible with any option that specifies an API for reads")
}

g, err := gapic.NewClient(ctx, s.clientOption...)
if err != nil {
return nil, err
Expand Down Expand Up @@ -885,11 +891,13 @@ func (c *grpcStorageClient) NewRangeReader(ctx context.Context, params *newRange
cc, cancel := context.WithCancel(ctx)

start := params.offset + seen

// Only set a ReadLimit if length is greater than zero, because zero
// means read it all.
if params.length > 0 {
req.ReadLimit = params.length - seen
}

req.ReadOffset = start

if err := applyCondsProto("gRPCReader.reopen", params.gen, params.conds, req); err != nil {
Expand Down
Loading

0 comments on commit 574a86c

Please sign in to comment.