Added zrpc server custom serverID for custom registration Key when the service is registered on ETCD. (#3008)

This commit is contained in:
Shyunn
2023-03-11 14:34:28 +08:00
committed by GitHub
parent 4cef2b412c
commit 544aa7c432
4 changed files with 44 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package clientinterceptors
import (
"context"
"github.com/zeromicro/go-zero/core/lang"
"io"
ztrace "github.com/zeromicro/go-zero/core/trace"
@@ -94,7 +95,7 @@ type (
Finished chan error
desc *grpc.StreamDesc
events chan streamEvent
eventsDone chan struct{}
eventsDone chan lang.PlaceholderType
receivedMessageID int
sentMessageID int
}

View File

@@ -26,6 +26,9 @@ func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, middlewares ServerMi
pubOpts = append(pubOpts, discov.WithPubEtcdTLS(etcd.CertFile, etcd.CertKeyFile,
etcd.CACertFile, etcd.InsecureSkipVerify))
}
if etcd.HasServerID() {
pubOpts = append(pubOpts, discov.WithId(etcd.ServerID))
}
pubClient := discov.NewPublisher(etcd.Hosts, etcd.Key, pubListenOn, pubOpts...)
return pubClient.KeepAlive()
}