Add etcd as a service discovery mechanism

This commit is contained in:
skiffer-git 2024-05-13 12:17:56 +08:00
parent e6c2bb0b6e
commit bb0da645a7

View File

@ -100,7 +100,7 @@ func (r *SvcDiscoveryRegistryImpl) GetConns(ctx context.Context, serviceName str
for _, kv := range resp.Kvs {
endpoint := string(kv.Key[len(fullServiceKey)+1:]) // Extract the endpoint address
target := fmt.Sprintf("etcd://%s", endpoint)
target := fmt.Sprintf("etcd://%s/%s/%s", r.rootDirectory, serviceName, endpoint)
conn, err := grpc.DialContext(ctx, target, append(append(r.dialOptions, opts...), grpc.WithResolvers(r.resolver))...)
if err != nil {
fmt.Println("DialContext ", target, err.Error())