From 7e3722c9c463f225ca20f35298c5bcc55ad04469 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 11 May 2024 17:39:15 +0800 Subject: [PATCH] Add etcd as a service discovery mechanism --- pkg/common/discoveryregister/etcd/etcd.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/discoveryregister/etcd/etcd.go b/pkg/common/discoveryregister/etcd/etcd.go index d9eb86aa3..741ceb8b1 100644 --- a/pkg/common/discoveryregister/etcd/etcd.go +++ b/pkg/common/discoveryregister/etcd/etcd.go @@ -85,7 +85,7 @@ func (r *SvcDiscoveryRegistryImpl) GetUserIdHashGatewayHost(ctx context.Context, // GetConns returns gRPC client connections for a given service name func (r *SvcDiscoveryRegistryImpl) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) { - target := fmt.Sprintf("etcd:///%s", serviceName) + target := fmt.Sprintf("etcd:///%s/%s", r.rootDirectory, serviceName) conn, err := grpc.DialContext(ctx, target, append(append(r.dialOptions, opts...), grpc.WithResolvers(r.resolver))...) if err != nil { return nil, err @@ -95,7 +95,7 @@ func (r *SvcDiscoveryRegistryImpl) GetConns(ctx context.Context, serviceName str // GetConn returns a single gRPC client connection for a given service name func (r *SvcDiscoveryRegistryImpl) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) { - target := fmt.Sprintf("etcd:///%s", serviceName) + target := fmt.Sprintf("etcd:///%s/%s", r.rootDirectory, serviceName) return grpc.DialContext(ctx, target, append(append(r.dialOptions, opts...), grpc.WithResolvers(r.resolver))...) }