Skip to content

Commit 932cb95

Browse files
committed
resolver: cleanup of deprecated grpc resolver target.Endpoint field
target.Endpoint and some other fields are deprecated, URL field is suggested to use instead path is required to be stripped of "/" prefix for naming/resolver to work porperly Signed-off-by: Ramil Mirhasanov <[email protected]>
1 parent 142fa76 commit 932cb95

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

client/v3/naming/resolver/resolver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package resolver
1616

1717
import (
1818
"context"
19+
"strings"
1920
"sync"
2021

2122
clientv3 "go.etcd.io/etcd/client/v3"
@@ -31,9 +32,15 @@ type builder struct {
3132
}
3233

3334
func (b builder) Build(target gresolver.Target, cc gresolver.ClientConn, opts gresolver.BuildOptions) (gresolver.Resolver, error) {
35+
// Refer to https://github.com/grpc/grpc-go/blob/16d3df80f029f57cff5458f1d6da6aedbc23545d/clientconn.go#L1587-L1611
36+
endpoint := target.URL.Path
37+
if endpoint == "" {
38+
endpoint = target.URL.Opaque
39+
}
40+
endpoint = strings.TrimPrefix(endpoint, "/")
3441
r := &resolver{
3542
c: b.c,
36-
target: target.Endpoint,
43+
target: endpoint,
3744
cc: cc,
3845
}
3946
r.ctx, r.cancel = context.WithCancel(context.Background())

0 commit comments

Comments
 (0)