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:
authorAndrew Newdigate <andrew@gitlab.com>2018-11-16 16:43:08 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-11-16 16:43:08 +0300
commitbee7719e45ffa4602e7b431d6e36a22c8c502bb0 (patch)
tree2229ca5321d26a9dea9907372facbb84c963cdbc /client
parentf3840074e88b5c1cf6b78eaa28c5cfd6e1d76e2c (diff)
Upgrade grpc-go from v1.9.1 to v1.16.0 in preparation for correlation ids
Diffstat (limited to 'client')
-rw-r--r--client/dial.go44
-rw-r--r--client/dial_test.go50
2 files changed, 2 insertions, 92 deletions
diff --git a/client/dial.go b/client/dial.go
index 89f2a10b0..b92e5a0b2 100644
--- a/client/dial.go
+++ b/client/dial.go
@@ -1,12 +1,6 @@
package client
import (
- "fmt"
- "net"
- "net/url"
- "strings"
- "time"
-
"google.golang.org/grpc"
)
@@ -16,46 +10,12 @@ var DefaultDialOpts = []grpc.DialOption{
}
// Dial gitaly
+// Deprecated: Use grpc.Dial directly instead
func Dial(rawAddress string, connOpts []grpc.DialOption) (*grpc.ClientConn, error) {
- network, addr, err := parseAddress(rawAddress)
- if err != nil {
- return nil, err
- }
-
- connOpts = append(connOpts,
- grpc.WithDialer(func(a string, timeout time.Duration) (net.Conn, error) {
- return net.DialTimeout(network, a, timeout)
- }))
- conn, err := grpc.Dial(addr, connOpts...)
+ conn, err := grpc.Dial(rawAddress, connOpts...)
if err != nil {
return nil, err
}
return conn, nil
}
-
-func parseAddress(rawAddress string) (network, addr string, err error) {
- // Parsing unix:// URL's with url.Parse does not give the result we want
- // so we do it manually.
- for _, prefix := range []string{"unix://", "unix:"} {
- if strings.HasPrefix(rawAddress, prefix) {
- return "unix", strings.TrimPrefix(rawAddress, prefix), nil
- }
- }
-
- u, err := url.Parse(rawAddress)
- if err != nil {
- return "", "", err
- }
-
- if u.Scheme != "tcp" {
- return "", "", fmt.Errorf("unknown scheme: %q", rawAddress)
- }
- if u.Host == "" {
- return "", "", fmt.Errorf("network tcp requires host: %q", rawAddress)
- }
- if u.Path != "" {
- return "", "", fmt.Errorf("network tcp should have no path: %q", rawAddress)
- }
- return "tcp", u.Host, nil
-}
diff --git a/client/dial_test.go b/client/dial_test.go
deleted file mode 100644
index d0513fc81..000000000
--- a/client/dial_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package client
-
-import (
- "testing"
-)
-
-func TestParseAddress(t *testing.T) {
- testCases := []struct {
- raw string
- network string
- addr string
- invalid bool
- }{
- {raw: "unix:/foo/bar.socket", network: "unix", addr: "/foo/bar.socket"},
- {raw: "unix:///foo/bar.socket", network: "unix", addr: "/foo/bar.socket"},
- // Mainly for test purposes we explicitly want to support relative paths
- {raw: "unix://foo/bar.socket", network: "unix", addr: "foo/bar.socket"},
- {raw: "unix:foo/bar.socket", network: "unix", addr: "foo/bar.socket"},
- {raw: "tcp://1.2.3.4", network: "tcp", addr: "1.2.3.4"},
- {raw: "tcp://1.2.3.4:567", network: "tcp", addr: "1.2.3.4:567"},
- {raw: "tcp://foobar", network: "tcp", addr: "foobar"},
- {raw: "tcp://foobar:567", network: "tcp", addr: "foobar:567"},
- {raw: "tcp://1.2.3.4/foo/bar.socket", invalid: true},
- {raw: "tcp:///foo/bar.socket", invalid: true},
- {raw: "tcp:/foo/bar.socket", invalid: true},
- }
-
- for _, tc := range testCases {
- network, addr, err := parseAddress(tc.raw)
-
- if err == nil && tc.invalid {
- t.Errorf("%v: expected error, got none", tc)
- } else if err != nil && !tc.invalid {
- t.Errorf("%v: parse error: %v", tc, err)
- continue
- }
-
- if tc.invalid {
- continue
- }
-
- if tc.network != network {
- t.Errorf("%v: expected %q, got %q", tc, tc.network, network)
- }
-
- if tc.addr != addr {
- t.Errorf("%v: expected %q, got %q", tc, tc.addr, addr)
- }
- }
-}