Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit 619d4b9

Browse files
author
Bryan C. Mills
committed
make v1 a type alias of v2; add go.mod
This change replicates googleapis#61 using the 'goforward' tool (https://golang.org/cl/137076) plus a few manual deletions. Tested using 'go test ./...'.
1 parent b001040 commit 619d4b9

File tree

9 files changed

+105
-432
lines changed

9 files changed

+105
-432
lines changed

call_option.go

Lines changed: 0 additions & 157 deletions
This file was deleted.

call_option_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ import (
3737
"google.golang.org/grpc/status"
3838
)
3939

40-
var _ Retryer = &boRetryer{}
41-
4240
func TestBackofDefault(t *testing.T) {
4341
backoff := Backoff{}
4442

@@ -47,11 +45,9 @@ func TestBackofDefault(t *testing.T) {
4745
max[i] = m * time.Second
4846
}
4947

50-
for i, w := range max {
48+
for _, w := range max {
5149
if d := backoff.Pause(); d > w {
5250
t.Errorf("Backoff duration should be at most %s, got %s", w, d)
53-
} else if i < len(max)-1 && backoff.cur != max[i+1] {
54-
t.Errorf("current envelope is %s, want %s", backoff.cur, max[i+1])
5551
}
5652
}
5753
}

forward.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package gax
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
gax "github.com/googleapis/gax-go/v2"
8+
"google.golang.org/grpc"
9+
"google.golang.org/grpc/codes"
10+
)
11+
12+
// generated by goforward -replace github.com/googleapis/gax-go/v2 github.com/googleapis/gax-go
13+
14+
// CallOption is an option used by Invoke to control behaviors of RPC calls.
15+
// CallOption works by modifying relevant fields of CallSettings.
16+
type CallOption = gax.CallOption
17+
18+
// Retryer is used by Invoke to determine retry behavior.
19+
type Retryer = gax.Retryer
20+
21+
// WithRetry sets CallSettings.Retry to fn.
22+
func WithRetry(fn func() Retryer) CallOption {
23+
return gax.WithRetry(fn)
24+
}
25+
26+
// OnCodes returns a Retryer that retries if and only if
27+
// the previous attempt returns a GRPC error whose error code is stored in cc.
28+
// Pause times between retries are specified by bo.
29+
//
30+
// bo is only used for its parameters; each Retryer has its own copy.
31+
func OnCodes(cc []codes.Code, bo Backoff) Retryer {
32+
return gax.OnCodes(cc, bo)
33+
}
34+
35+
// Backoff implements exponential backoff.
36+
// The wait time between retries is a random value between 0 and the "retry envelope".
37+
// The envelope starts at Initial and increases by the factor of Multiplier every retry,
38+
// but is capped at Max.
39+
type Backoff = gax.Backoff
40+
41+
func WithGRPCOptions(opt ...grpc.CallOption) CallOption {
42+
return gax.WithGRPCOptions(opt...)
43+
}
44+
45+
type CallSettings = gax.CallSettings
46+
47+
const Version = gax.Version
48+
49+
// XGoogHeader is for use by the Google Cloud Libraries only.
50+
//
51+
// XGoogHeader formats key-value pairs.
52+
// The resulting string is suitable for x-goog-api-client header.
53+
func XGoogHeader(keyval ...string) string {
54+
return gax.XGoogHeader(keyval...)
55+
}
56+
57+
// A user defined call stub.
58+
type APICall = gax.APICall
59+
60+
// Invoke calls the given APICall,
61+
// performing retries as specified by opts, if any.
62+
func Invoke(ctx context.Context, call APICall, opts ...CallOption) error {
63+
return gax.Invoke(ctx, call, opts...)
64+
}
65+
66+
// Sleep is similar to time.Sleep, but it can be interrupted by ctx.Done() closing.
67+
// If interrupted, Sleep returns ctx.Err().
68+
func Sleep(ctx context.Context, d time.Duration) error {
69+
return gax.Sleep(ctx, d)
70+
}

gax.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,3 @@
3434
// However, code generated automatically from API definition files can use it
3535
// to simplify code generation and to provide more convenient and idiomatic API surfaces.
3636
package gax
37-
38-
const Version = "2.0.0"

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module github.com/googleapis/gax-go
2+
3+
require (
4+
github.com/googleapis/gax-go/v2 v2.0.2
5+
google.golang.org/grpc v1.16.0
6+
)

go.sum

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2+
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
3+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
4+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
5+
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
6+
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
7+
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
8+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
9+
github.com/googleapis/gax-go/v2 v2.0.2 h1:/rNgUniLy2vDXiK2xyJOcirGpC3G99dtK1NWx26WZ8Y=
10+
github.com/googleapis/gax-go/v2 v2.0.2/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg=
11+
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
12+
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
13+
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I=
14+
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
15+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
16+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
17+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
18+
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
19+
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
20+
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
21+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
22+
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
23+
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
24+
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
25+
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
26+
google.golang.org/grpc v1.16.0 h1:dz5IJGuC2BB7qXR5AyHNwAUBhZscK2xVez7mznh72sY=
27+
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
28+
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

header.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)