mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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 <ramil600@yahoo.com>
This commit is contained in:
parent
142fa76a11
commit
932cb95e37
@ -16,6 +16,7 @@ package resolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
@ -31,9 +32,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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user