Skip to content

Commit

Permalink
resolver: cleanup of deprecated grpc resolver target.Endpoint field
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ramil600 authored and rsafonseca committed Sep 13, 2023
1 parent d93b249 commit cf585bc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/v3/naming/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resolver

import (
"context"
"strings"
"sync"

clientv3 "go.etcd.io/etcd/client/v3"
Expand All @@ -17,9 +18,15 @@ type builder struct {
}

func (b builder) Build(target gresolver.Target, cc gresolver.ClientConn, opts gresolver.BuildOptions) (gresolver.Resolver, error) {
// Refer to https://github.com/grpc/grpc-go/blob/16d3df80f029f57cff5458f1d6da6aedbc23545d/clientconn.go#L1587-L1611
endpoint := target.URL.Path
if endpoint == "" {
endpoint = target.URL.Opaque
}
endpoint = strings.TrimPrefix(endpoint, "/")
r := &resolver{
c: b.c,
target: target.Endpoint,
target: endpoint,
cc: cc,
}
r.ctx, r.cancel = context.WithCancel(context.Background())
Expand Down

0 comments on commit cf585bc

Please sign in to comment.