Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-03-20 09:28:52 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-03-25 11:58:39 +0300
commitd756ece7e0505ceed1f950c86ad1bb4c28bfca75 (patch)
tree0c30f5ca893b1b31690685f844d73512ebc67d87 /client
parent1a7f1f093c72db7634bf7109f14baf0d6c4a703a (diff)
grpc: Replace `grpc.WithTimeout()` with contexts
The `grpc.WithTimeout()` function has been deprecated upstream in favor of using the `context` package. This commit converts all uses of the derpecated function with using a context created via `context.WithTimeout()`. As we have abstracted away dialing Gitaly via `client.Dial()`, this commit also introduces a new function `client.DialContext()` and makes `client.Dial()` a thin wrapper around the latter.
Diffstat (limited to 'client')
-rw-r--r--client/dial.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/client/dial.go b/client/dial.go
index 12ada0acb..4a1072c52 100644
--- a/client/dial.go
+++ b/client/dial.go
@@ -25,8 +25,7 @@ const (
unixConnection
)
-// Dial gitaly
-func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, error) {
+func DialContext(ctx context.Context, rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, error) {
var canonicalAddress string
var err error
@@ -80,7 +79,7 @@ func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, erro
PermitWithoutStream: true,
}))
- conn, err := grpc.Dial(canonicalAddress, connOpts...)
+ conn, err := grpc.DialContext(ctx, canonicalAddress, connOpts...)
if err != nil {
return nil, err
}
@@ -88,6 +87,10 @@ func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, erro
return conn, nil
}
+func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, error) {
+ return DialContext(context.Background(), rawAddress, connOpts)
+}
+
func getConnectionType(rawAddress string) connectionType {
u, err := url.Parse(rawAddress)
if err != nil {