Skip to content

Commit

Permalink
Merge branch 'main' into fix-data-race
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Jan 6, 2022
2 parents 759fd0f + bc97804 commit 2b5ecea
Show file tree
Hide file tree
Showing 15 changed files with 757 additions and 43 deletions.
9 changes: 9 additions & 0 deletions bigquery/CHANGES.md
@@ -1,5 +1,14 @@
# Changes

## [1.26.0](https://www.github.com/googleapis/google-cloud-go/compare/bigquery/v1.25.0...bigquery/v1.26.0) (2022-01-04)


### Features

* **bigquery/reservation:** increase the logical timeout (retry deadline) to 5 minutes ([5444809](https://www.github.com/googleapis/google-cloud-go/commit/5444809e0b7cf9f5416645ea2df6fec96f8b9023))
* **bigquery/storage/managedwriter:** support schema change notification ([#5253](https://www.github.com/googleapis/google-cloud-go/issues/5253)) ([70e40db](https://www.github.com/googleapis/google-cloud-go/commit/70e40db88bc016f228a425da1e278fc76dbf2e36))
* **bigquery/storage:** add write_mode support for BigQuery Storage Write API v1 ([615b42b](https://www.github.com/googleapis/google-cloud-go/commit/615b42bbb549b6fd3e8b1ba751bc109f79a5575b))

## [1.25.0](https://www.github.com/googleapis/google-cloud-go/compare/bigquery/v1.24.0...bigquery/v1.25.0) (2021-12-02)


Expand Down
6 changes: 6 additions & 0 deletions compute/CHANGES.md
@@ -0,0 +1,6 @@
# Changes

## v0.1.0

This is the first tag to carve out compute as its own module. See
[Add a module to a multi-module repository](https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository).
40 changes: 40 additions & 0 deletions compute/README.md
@@ -0,0 +1,40 @@
# Compute API

[![Go Reference](https://pkg.go.dev/badge/cloud.google.com/go/compute.svg)](https://pkg.go.dev/cloud.google.com/go/compute)

Go Client Library for Compute API.

## Install

```bash
go get cloud.google.com/go/compute
```

## Stability

The stability of this module is indicated by SemVer.

However, a `v1+` module may have breaking changes in two scenarios:

* Packages with `alpha` or `beta` in the import path
* The GoDoc has an explicit stability disclaimer (for example, for an experimental feature).

## Go Version Support

See the [Go Versions Supported](https://github.com/googleapis/google-cloud-go#go-versions-supported)
section in the root directory's README.

## Authorization

See the [Authorization](https://github.com/googleapis/google-cloud-go#authorization)
section in the root directory's README.

## Contributing

Contributions are welcome. Please, see the [CONTRIBUTING](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md)
document for details.

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms. See
[Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md#contributor-code-of-conduct)
for more information.
14 changes: 14 additions & 0 deletions compute/go.mod
@@ -0,0 +1,14 @@
module cloud.google.com/go/compute

go 1.11

require (
cloud.google.com/go v0.100.2
github.com/google/go-cmp v0.5.6
github.com/googleapis/gax-go/v2 v2.1.1
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/api v0.63.0
google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c
google.golang.org/grpc v1.40.1
google.golang.org/protobuf v1.27.1
)
563 changes: 563 additions & 0 deletions compute/go.sum

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions compute/go_mod_tidy_hack.go
@@ -0,0 +1,23 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file, and the cloud.google.com/go import, won't actually become part of
// the resultant binary.
//go:build modhack
// +build modhack

package compute

// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository
import _ "cloud.google.com/go"
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -3,6 +3,7 @@ module cloud.google.com/go
go 1.11

require (
cloud.google.com/go/compute v0.1.0
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6
github.com/google/martian/v3 v3.2.1
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Expand Up @@ -26,12 +26,15 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y
cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4=
cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc=
cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA=
cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/compute v0.1.0 h1:rSUBvAyVwNJ5uQCKNJFMwPtTvJkfN38b6Pvb9zZoqJ8=
cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
Expand Down
3 changes: 2 additions & 1 deletion internal/generated/snippets/go.mod
Expand Up @@ -23,7 +23,7 @@ replace cloud.google.com/go/spanner => ../../../spanner
replace cloud.google.com/go/storage => ../../../storage

require (
cloud.google.com/go v0.100.1
cloud.google.com/go v0.100.2
cloud.google.com/go/accessapproval v0.1.0
cloud.google.com/go/accesscontextmanager v0.1.0
cloud.google.com/go/aiplatform v0.1.0
Expand All @@ -43,6 +43,7 @@ require (
cloud.google.com/go/cloudbuild v0.1.0
cloud.google.com/go/clouddms v0.1.0
cloud.google.com/go/cloudtasks v0.1.0
cloud.google.com/go/compute v0.1.0
cloud.google.com/go/contactcenterinsights v0.1.0
cloud.google.com/go/container v0.1.0
cloud.google.com/go/containeranalysis v0.1.0
Expand Down
2 changes: 2 additions & 0 deletions internal/generated/snippets/go.sum
@@ -1,3 +1,5 @@
cloud.google.com/go/compute v0.1.0 h1:rSUBvAyVwNJ5uQCKNJFMwPtTvJkfN38b6Pvb9zZoqJ8=
cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow=
cloud.google.com/go/iam v0.1.0 h1:W2vbGCrE3Z7J/x3WXLxxGl9LMSB2uhsAA7Ss/6u/qRY=
cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down
2 changes: 1 addition & 1 deletion internal/godocfx/go.mod
Expand Up @@ -3,7 +3,7 @@ module cloud.google.com/go/internal/godocfx
go 1.15

require (
cloud.google.com/go v0.100.1
cloud.google.com/go v0.100.2
cloud.google.com/go/bigquery v1.25.0
cloud.google.com/go/datastore v1.6.0
cloud.google.com/go/iam v0.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions internal/godocfx/go.sum
Expand Up @@ -5,6 +5,8 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/bigquery v1.25.0 h1:8MQohtqep0hpDh5PGy3juVaawv9l5335EX27SeeE1qo=
cloud.google.com/go/bigquery v1.25.0/go.mod h1:4WtqW7wUNz7dklHMg62ST1k97dQrsnZN5iCeZYrIsC8=
cloud.google.com/go/compute v0.1.0 h1:rSUBvAyVwNJ5uQCKNJFMwPtTvJkfN38b6Pvb9zZoqJ8=
cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow=
cloud.google.com/go/datacatalog v1.0.0 h1:KHjIs525XbESSGHxwEKHTzkwfvj7xxYrCy4gcvvlHBY=
cloud.google.com/go/datacatalog v1.0.0/go.mod h1:cz8rXsZV278v0nXPhnp5eXRnZtqx2Mtv96W8r7a7Oxs=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
Expand Down
4 changes: 2 additions & 2 deletions internal/godocfx/testdata/golden/index.yml
Expand Up @@ -832,8 +832,8 @@ items:
- go
syntax:
content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>)
IAM() *<a href="/go/docs/reference/cloud.google.com/go/latest/iam">iam</a>.<a
href="/go/docs/reference/cloud.google.com/go/latest/iam#cloud_google_com_go_iam_Handle">Handle</a>
IAM() *<a href="/go/docs/reference/cloud.google.com/go/iam/latest/">iam</a>.<a
href="/go/docs/reference/cloud.google.com/go/iam/latest/#cloud_google_com_go_iam_Handle">Handle</a>
- uid: cloud.google.com/go/storage.BucketHandle.If
name: |
func (*BucketHandle) If
Expand Down
15 changes: 0 additions & 15 deletions storage/invoke.go
Expand Up @@ -55,21 +55,6 @@ func run(ctx context.Context, call func() error, retry *retryConfig, isIdempoten
})
}

// runWithRetry calls the function until it returns nil or a non-retryable error, or
// the context is done.
func runWithRetry(ctx context.Context, call func() error) error {
return internal.Retry(ctx, gax.Backoff{}, func() (stop bool, err error) {
err = call()
if err == nil {
return true, nil
}
if shouldRetry(err) {
return false, err
}
return true, err
})
}

func shouldRetry(err error) bool {
if err == nil {
return false
Expand Down
113 changes: 89 additions & 24 deletions storage/invoke_test.go
Expand Up @@ -33,32 +33,97 @@ func TestInvoke(t *testing.T) {
// returns with the right error.

for _, test := range []struct {
count int // Number of times to return retryable error.
initialErr error // Error to return initially.
finalErr error // Error to return after count returns of retryCode.
count int // Number of times to return retryable error.
initialErr error // Error to return initially.
finalErr error // Error to return after count returns of retryCode.
retry *retryConfig
isIdempotentValue bool
expectFinalErr bool
}{
{0, &googleapi.Error{Code: 0}, nil},
{0, &googleapi.Error{Code: 0}, errors.New("foo")},
{1, &googleapi.Error{Code: 429}, nil},
{1, &googleapi.Error{Code: 429}, errors.New("bar")},
{2, &googleapi.Error{Code: 518}, nil},
{2, &googleapi.Error{Code: 599}, &googleapi.Error{Code: 428}},
{1, &url.Error{Op: "blah", URL: "blah", Err: errors.New("connection refused")}, nil},
{1, io.ErrUnexpectedEOF, nil},
{1, xerrors.Errorf("Test unwrapping of a temporary error: %w", &googleapi.Error{Code: 500}), nil},
{0, xerrors.Errorf("Test unwrapping of a non-retriable error: %w", &googleapi.Error{Code: 400}), &googleapi.Error{Code: 400}},
{
count: 0,
initialErr: &googleapi.Error{Code: 0},
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 0,
initialErr: &googleapi.Error{Code: 0},
finalErr: errors.New("foo"),
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 1,
initialErr: &googleapi.Error{Code: 429},
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 1,
initialErr: &googleapi.Error{Code: 429},
finalErr: errors.New("bar"),
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 2,
initialErr: &googleapi.Error{Code: 518},
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 2,
initialErr: &googleapi.Error{Code: 599},
finalErr: &googleapi.Error{Code: 428},
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 1,
initialErr: &url.Error{Op: "blah", URL: "blah", Err: errors.New("connection refused")},
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 1,
initialErr: io.ErrUnexpectedEOF,
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 1,
initialErr: xerrors.Errorf("Test unwrapping of a temporary error: %w", &googleapi.Error{Code: 500}),
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
count: 0,
initialErr: xerrors.Errorf("Test unwrapping of a non-retriable error: %w", &googleapi.Error{Code: 400}),
finalErr: &googleapi.Error{Code: 400},
isIdempotentValue: true,
expectFinalErr: true,
},
} {
counter := 0
call := func() error {
counter++
if counter <= test.count {
return test.initialErr
t.Run("", func(s *testing.T) {
counter := 0
call := func() error {
counter++
if counter <= test.count {
return test.initialErr
}
return test.finalErr
}
return test.finalErr
}
got := runWithRetry(ctx, call)
if got != test.finalErr {
t.Errorf("%+v: got %v, want %v", test, got, test.finalErr)
}
got := run(ctx, call, test.retry, test.isIdempotentValue)
if got != test.finalErr {
s.Errorf("%+v: got %v, want %v", test, got, test.finalErr)
}
})
}
}

0 comments on commit 2b5ecea

Please sign in to comment.