feat: support auth account for etcd (#1174)

This commit is contained in:
Kevin Wan
2021-10-31 09:05:38 +08:00
committed by GitHub
parent c1a8ccda11
commit 59b9687f31
15 changed files with 204 additions and 29 deletions

View File

@@ -14,11 +14,14 @@ const (
)
// NewRpcPubServer returns a Server.
func NewRpcPubServer(etcdEndpoints []string, etcdKey, listenOn string,
opts ...ServerOption) (Server, error) {
func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, opts ...ServerOption) (Server, error) {
registerEtcd := func() error {
pubListenOn := figureOutListenOn(listenOn)
pubClient := discov.NewPublisher(etcdEndpoints, etcdKey, pubListenOn)
var pubOpts []discov.PubOption
if etcd.HasAccount() {
pubOpts = append(pubOpts, discov.WithPubEtcdAccount(etcd.User, etcd.Pass))
}
pubClient := discov.NewPublisher(etcd.Hosts, etcd.Key, pubListenOn, pubOpts...)
return pubClient.KeepAlive()
}
server := keepAliveServer{