Skip to content

Commit

Permalink
Enable using gRPC client for GCS
Browse files Browse the repository at this point in the history
GCP has an experimental feature which allows using gRPC when talking to GCS.
For the time being, it requires buckets to be explicitly added to an allowlist,
but eventually the feature will become GA.

This commit allows using a gRPC client when creating a GCS bucket by toggling
a boolean flag in the bucket config.

Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed Dec 6, 2023
1 parent bffedaa commit 008a3c9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion providers/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DirDelim = "/"
type Config struct {
Bucket string `yaml:"bucket"`
ServiceAccount string `yaml:"service_account"`
UseGRPC bool `yaml:"use_grpc"`
}

// Bucket implements the store.Bucket and shipper.Bucket interfaces against GCS.
Expand Down Expand Up @@ -75,7 +76,19 @@ func NewBucketWithConfig(ctx context.Context, logger log.Logger, gc Config, comp
option.WithUserAgent(fmt.Sprintf("thanos-%s/%s (%s)", component, version.Version, runtime.Version())),
)

gcsClient, err := storage.NewClient(ctx, opts...)
return newBucket(ctx, logger, gc, opts)
}

func newBucket(ctx context.Context, logger log.Logger, gc Config, opts []option.ClientOption) (*Bucket, error) {
var (
err error
gcsClient *storage.Client
)
if gc.UseGRPC {
gcsClient, err = storage.NewGRPCClient(ctx, opts...)
} else {
gcsClient, err = storage.NewClient(ctx, opts...)
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 008a3c9

Please sign in to comment.