mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-28 10:00:25 +08:00
优化etcd发现服务,支持记录附加信息rpc
This commit is contained in:
@@ -62,7 +62,7 @@ func (cls *Cluster) setupConfigDiscovery(localNodeId string, setupServiceFun Set
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) GetOriginDiscoveryNodeList() []NodeInfo {
|
func (cls *Cluster) GetOriginDiscovery() *OriginDiscovery {
|
||||||
return cls.discoveryInfo.Origin
|
return cls.discoveryInfo.Origin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -38,7 +39,7 @@ type EtcdDiscoveryService struct {
|
|||||||
byteLocalNodeInfo string
|
byteLocalNodeInfo string
|
||||||
mapClient map[*clientv3.Client]*etcdClientInfo
|
mapClient map[*clientv3.Client]*etcdClientInfo
|
||||||
isClose int32
|
isClose int32
|
||||||
|
bRetire bool
|
||||||
mapDiscoveryNodeId map[string]map[string]struct{} //map[networkName]map[nodeId]
|
mapDiscoveryNodeId map[string]map[string]struct{} //map[networkName]map[nodeId]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +101,8 @@ func (ed *EtcdDiscoveryService) OnInit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx,_:=context.WithTimeout(context.Background(),time.Second*3)
|
ctx,_:=context.WithTimeout(context.Background(),time.Second*3)
|
||||||
_,err = client.Put(ctx,testKey,"")
|
_,err = client.Leases(ctx)
|
||||||
|
//_,err = client.Put(ctx,testKey,"")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("etcd discovery init fail",log.Any("endpoint",etcdDiscoveryCfg.EtcdList[i].Endpoints),log.ErrorAttr("err",err))
|
log.Error("etcd discovery init fail",log.Any("endpoint",etcdDiscoveryCfg.EtcdList[i].Endpoints),log.ErrorAttr("err",err))
|
||||||
return err
|
return err
|
||||||
@@ -186,9 +188,37 @@ func (ed *EtcdDiscoveryService) tryWatch(client *clientv3.Client,etcdClient *etc
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ed *EtcdDiscoveryService) tryLaterRetire() {
|
||||||
|
ed.AfterFunc(time.Second, func(*timer.Timer) {
|
||||||
|
if ed.retire() != nil {
|
||||||
|
ed.tryLaterRetire()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *EtcdDiscoveryService) retire() error{
|
||||||
|
//从etcd中更新
|
||||||
|
for c,ec := range ed.mapClient {
|
||||||
|
for _, watchKey := range ec.watchKeys {
|
||||||
|
// 注册服务节点到 etcd
|
||||||
|
_, err := c.Put(context.Background(), ed.getRegisterKey(watchKey), ed.byteLocalNodeInfo, clientv3.WithLease(ec.leaseID))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("etcd Put fail", log.ErrorAttr("err", err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (ed *EtcdDiscoveryService) OnRetire(){
|
func (ed *EtcdDiscoveryService) OnRetire(){
|
||||||
atomic.StoreInt32(&ed.isClose,1)
|
ed.bRetire = true
|
||||||
ed.close()
|
ed.marshalNodeInfo()
|
||||||
|
|
||||||
|
if ed.retire()!= nil {
|
||||||
|
ed.tryLaterRetire()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ed *EtcdDiscoveryService) OnRelease(){
|
func (ed *EtcdDiscoveryService) OnRelease(){
|
||||||
@@ -212,7 +242,7 @@ func (ed *EtcdDiscoveryService) marshalNodeInfo() error{
|
|||||||
var nodeInfo rpc.NodeInfo
|
var nodeInfo rpc.NodeInfo
|
||||||
nodeInfo.NodeId = nInfo.NodeId
|
nodeInfo.NodeId = nInfo.NodeId
|
||||||
nodeInfo.ListenAddr = nInfo.ListenAddr
|
nodeInfo.ListenAddr = nInfo.ListenAddr
|
||||||
nodeInfo.Retire = nInfo.Retire
|
nodeInfo.Retire = ed.bRetire
|
||||||
nodeInfo.PublicServiceList = nInfo.PublicServiceList
|
nodeInfo.PublicServiceList = nInfo.PublicServiceList
|
||||||
nodeInfo.MaxRpcParamLen = nInfo.MaxRpcParamLen
|
nodeInfo.MaxRpcParamLen = nInfo.MaxRpcParamLen
|
||||||
|
|
||||||
@@ -344,7 +374,7 @@ func (ed *EtcdDiscoveryService) delNode(fullKey string) string{
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
ed.funDelNode(nodeId,true)
|
ed.funDelNode(nodeId,false)
|
||||||
return nodeId
|
return nodeId
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +445,7 @@ func (ed *EtcdDiscoveryService) OnEventGets(watchKey string,Kvs []*mvccpb.KeyVal
|
|||||||
mapLastNodeId := ed.mapDiscoveryNodeId[watchKey] // 根据watchKey获取对应的节点ID集合
|
mapLastNodeId := ed.mapDiscoveryNodeId[watchKey] // 根据watchKey获取对应的节点ID集合
|
||||||
for nodeId := range mapLastNodeId { // 遍历所有节点ID
|
for nodeId := range mapLastNodeId { // 遍历所有节点ID
|
||||||
if _,ok := mapNode[nodeId];ok == false && nodeId != ed.localNodeId { // 检查节点是否不存在于mapNode且不是本地节点
|
if _,ok := mapNode[nodeId];ok == false && nodeId != ed.localNodeId { // 检查节点是否不存在于mapNode且不是本地节点
|
||||||
ed.funDelNode(nodeId,true) // 调用函数删除该节点
|
ed.funDelNode(nodeId,false) // 调用函数删除该节点
|
||||||
delete(ed.mapDiscoveryNodeId[watchKey],nodeId)
|
delete(ed.mapDiscoveryNodeId[watchKey],nodeId)
|
||||||
log.Debug(">>etcd OnEventGets Delete",log.String("watchKey",watchKey),log.String("nodeId",nodeId))
|
log.Debug(">>etcd OnEventGets Delete",log.String("watchKey",watchKey),log.String("nodeId",nodeId))
|
||||||
}
|
}
|
||||||
@@ -441,3 +471,56 @@ func (ed *EtcdDiscoveryService) addNodeId(watchKey string,nodeId string) {
|
|||||||
|
|
||||||
ed.mapDiscoveryNodeId[watchKey][nodeId] = struct{}{}
|
ed.mapDiscoveryNodeId[watchKey][nodeId] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ed *EtcdDiscoveryService) OnNodeDisconnect(nodeId string) {
|
||||||
|
//将Discard结点清理
|
||||||
|
cluster.DiscardNode(nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ed *EtcdDiscoveryService) RPC_ServiceRecord(etcdServiceRecord *service.EtcdServiceRecordEvent,empty *service.Empty) error{
|
||||||
|
var client *clientv3.Client
|
||||||
|
|
||||||
|
//写入到etcd中
|
||||||
|
for c, info := range ed.mapClient{
|
||||||
|
for _,watchKey := range info.watchKeys {
|
||||||
|
if ed.getNetworkNameByWatchKey(watchKey) == etcdServiceRecord.NetworkName {
|
||||||
|
client = c
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if client == nil {
|
||||||
|
log.Error("etcd record fail,cannot find network name",log.String("networkName",etcdServiceRecord.NetworkName))
|
||||||
|
return errors.New("annot find network name")
|
||||||
|
}
|
||||||
|
|
||||||
|
var lg *clientv3.LeaseGrantResponse
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if etcdServiceRecord.TTLSecond > 0 {
|
||||||
|
ctx,_:=context.WithTimeout(context.Background(),time.Second*3)
|
||||||
|
lg, err = client.Grant(ctx, etcdServiceRecord.TTLSecond)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("etcd record fail,cannot grant lease",log.ErrorAttr("err",err))
|
||||||
|
return errors.New("cannot grant lease")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if lg != nil {
|
||||||
|
ctx,_:=context.WithTimeout(context.Background(),time.Second*3)
|
||||||
|
_, err = client.Put(ctx, path.Join(originDir,etcdServiceRecord.RecordKey),etcdServiceRecord.RecordInfo, clientv3.WithLease(lg.ID))
|
||||||
|
if err != nil {
|
||||||
|
log.Error("etcd record fail,cannot put record",log.ErrorAttr("err",err))
|
||||||
|
}
|
||||||
|
return errors.New("cannot put record")
|
||||||
|
}
|
||||||
|
|
||||||
|
_,err = client.Put(context.Background(), path.Join(originDir,etcdServiceRecord.RecordKey),etcdServiceRecord.RecordInfo)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("etcd record fail,cannot put record",log.ErrorAttr("err",err))
|
||||||
|
return errors.New("cannot put record")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"github.com/duanhf2012/origin/v2/log"
|
"github.com/duanhf2012/origin/v2/log"
|
||||||
"github.com/duanhf2012/origin/v2/rpc"
|
"github.com/duanhf2012/origin/v2/rpc"
|
||||||
"github.com/duanhf2012/origin/v2/service"
|
"github.com/duanhf2012/origin/v2/service"
|
||||||
"time"
|
|
||||||
"github.com/duanhf2012/origin/v2/util/timer"
|
"github.com/duanhf2012/origin/v2/util/timer"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const OriginDiscoveryMasterName = "DiscoveryMaster"
|
const OriginDiscoveryMasterName = "DiscoveryMaster"
|
||||||
@@ -16,6 +16,71 @@ const RegServiceDiscover = OriginDiscoveryMasterName + ".RPC_RegServiceDiscover"
|
|||||||
const SubServiceDiscover = OriginDiscoveryClientName + ".RPC_SubServiceDiscover"
|
const SubServiceDiscover = OriginDiscoveryClientName + ".RPC_SubServiceDiscover"
|
||||||
const AddSubServiceDiscover = OriginDiscoveryMasterName + ".RPC_AddSubServiceDiscover"
|
const AddSubServiceDiscover = OriginDiscoveryMasterName + ".RPC_AddSubServiceDiscover"
|
||||||
const NodeRetireRpcMethod = OriginDiscoveryMasterName+".RPC_NodeRetire"
|
const NodeRetireRpcMethod = OriginDiscoveryMasterName+".RPC_NodeRetire"
|
||||||
|
//
|
||||||
|
//type nodeTTL struct {
|
||||||
|
// nodeId string
|
||||||
|
// refreshTime time.Time
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//type nodeSetTTL struct {
|
||||||
|
// l *list.List
|
||||||
|
// mapElement map[string]*list.Element
|
||||||
|
// ttl time.Duration
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (ns *nodeSetTTL) init(ttl time.Duration) {
|
||||||
|
// ns.ttl = ttl
|
||||||
|
// ns.mapElement = make(map[string]*list.Element,32)
|
||||||
|
// ns.l = list.New()
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (ns *nodeSetTTL) removeNode(nodeId string) {
|
||||||
|
// ele,ok:=ns.mapElement[nodeId]
|
||||||
|
// if ok == false {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ns.l.Remove(ele)
|
||||||
|
// delete(ns.mapElement,nodeId)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (ns *nodeSetTTL) addAndRefreshNode(nodeId string){
|
||||||
|
// ele,ok:=ns.mapElement[nodeId]
|
||||||
|
// if ok == false {
|
||||||
|
// ele = ns.l.PushBack(nodeId)
|
||||||
|
// ele.Value = &nodeTTL{nodeId,time.Now()}
|
||||||
|
// ns.mapElement[nodeId] = ele
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ele.Value.(*nodeTTL).refreshTime = time.Now()
|
||||||
|
// ns.l.MoveToBack(ele)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (ns *nodeSetTTL) checkTTL(cb func(nodeIdList []string)){
|
||||||
|
// nodeIdList := []string{}
|
||||||
|
// for{
|
||||||
|
// f := ns.l.Front()
|
||||||
|
// if f == nil {
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// nt := f.Value.(*nodeTTL)
|
||||||
|
// if time.Now().Sub(nt.refreshTime) > ns.ttl {
|
||||||
|
// nodeIdList = append(nodeIdList,nt.nodeId)
|
||||||
|
// }else{
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //删除结点
|
||||||
|
// ns.l.Remove(f)
|
||||||
|
// delete(ns.mapElement,nt.nodeId)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if len(nodeIdList) >0 {
|
||||||
|
// cb(nodeIdList)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
type OriginDiscoveryMaster struct {
|
type OriginDiscoveryMaster struct {
|
||||||
service.Service
|
service.Service
|
||||||
@@ -48,7 +113,6 @@ func init() {
|
|||||||
clientService.SetName(OriginDiscoveryClientName)
|
clientService.SetName(OriginDiscoveryClientName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (ds *OriginDiscoveryMaster) isRegNode(nodeId string) bool {
|
func (ds *OriginDiscoveryMaster) isRegNode(nodeId string) bool {
|
||||||
_, ok := ds.mapNodeInfo[nodeId]
|
_, ok := ds.mapNodeInfo[nodeId]
|
||||||
return ok
|
return ok
|
||||||
@@ -247,12 +311,14 @@ func (dc *OriginDiscoveryClient) OnStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dc *OriginDiscoveryClient) addDiscoveryMaster() {
|
func (dc *OriginDiscoveryClient) addDiscoveryMaster() {
|
||||||
discoveryNodeList := cluster.GetOriginDiscoveryNodeList()
|
discoveryNodeList := cluster.GetOriginDiscovery()
|
||||||
for i := 0; i < len(discoveryNodeList); i++ {
|
|
||||||
if discoveryNodeList[i].NodeId == cluster.GetLocalNodeInfo().NodeId {
|
for i := 0; i < len(discoveryNodeList.MasterNodeList); i++ {
|
||||||
|
if discoveryNodeList.MasterNodeList[i].NodeId == cluster.GetLocalNodeInfo().NodeId {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
dc.funSetNode(&discoveryNodeList[i])
|
dc.funSetNode(&discoveryNodeList.MasterNodeList[i])
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,8 +421,8 @@ func (dc *OriginDiscoveryClient) OnNodeConnected(nodeId string) {
|
|||||||
func (dc *OriginDiscoveryClient) OnRetire(){
|
func (dc *OriginDiscoveryClient) OnRetire(){
|
||||||
dc.bRetire = true
|
dc.bRetire = true
|
||||||
|
|
||||||
masterNodeList := cluster.GetOriginDiscoveryNodeList()
|
masterNodeList := cluster.GetOriginDiscovery()
|
||||||
for i:=0;i<len(masterNodeList);i++{
|
for i:=0;i<len(masterNodeList.MasterNodeList);i++{
|
||||||
var nodeRetireReq rpc.NodeRetireReq
|
var nodeRetireReq rpc.NodeRetireReq
|
||||||
|
|
||||||
nodeRetireReq.NodeInfo = &rpc.NodeInfo{}
|
nodeRetireReq.NodeInfo = &rpc.NodeInfo{}
|
||||||
@@ -367,13 +433,19 @@ func (dc *OriginDiscoveryClient) OnRetire(){
|
|||||||
nodeRetireReq.NodeInfo.Retire = dc.bRetire
|
nodeRetireReq.NodeInfo.Retire = dc.bRetire
|
||||||
nodeRetireReq.NodeInfo.Private = cluster.localNodeInfo.Private
|
nodeRetireReq.NodeInfo.Private = cluster.localNodeInfo.Private
|
||||||
|
|
||||||
err := dc.GoNode(masterNodeList[i].NodeId,NodeRetireRpcMethod,&nodeRetireReq)
|
err := dc.GoNode(masterNodeList.MasterNodeList[i].NodeId,NodeRetireRpcMethod,&nodeRetireReq)
|
||||||
if err!= nil {
|
if err!= nil {
|
||||||
log.Error("call "+NodeRetireRpcMethod+" is fail",log.ErrorAttr("err",err))
|
log.Error("call "+NodeRetireRpcMethod+" is fail",log.ErrorAttr("err",err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dc *OriginDiscoveryClient) tryRegServiceDiscover(nodeId string){
|
||||||
|
dc.AfterFunc(time.Second*3, func(timer *timer.Timer) {
|
||||||
|
dc.regServiceDiscover(nodeId)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (dc *OriginDiscoveryClient) regServiceDiscover(nodeId string){
|
func (dc *OriginDiscoveryClient) regServiceDiscover(nodeId string){
|
||||||
nodeInfo := cluster.getOriginMasterDiscoveryNodeInfo(nodeId)
|
nodeInfo := cluster.getOriginMasterDiscoveryNodeInfo(nodeId)
|
||||||
if nodeInfo == nil {
|
if nodeInfo == nil {
|
||||||
@@ -393,15 +465,14 @@ func (dc *OriginDiscoveryClient) regServiceDiscover(nodeId string){
|
|||||||
err := dc.AsyncCallNode(nodeId, RegServiceDiscover, &req, func(res *rpc.Empty, err error) {
|
err := dc.AsyncCallNode(nodeId, RegServiceDiscover, &req, func(res *rpc.Empty, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("call "+RegServiceDiscover+" is fail :"+ err.Error())
|
log.Error("call "+RegServiceDiscover+" is fail :"+ err.Error())
|
||||||
dc.AfterFunc(time.Second*3, func(timer *timer.Timer) {
|
dc.tryRegServiceDiscover(nodeId)
|
||||||
dc.regServiceDiscover(nodeId)
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("call "+ RegServiceDiscover+" is fail :"+ err.Error())
|
log.Error("call "+ RegServiceDiscover+" is fail :"+ err.Error())
|
||||||
|
dc.tryRegServiceDiscover(nodeId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +525,7 @@ func (cls *Cluster) checkOriginDiscovery(localNodeId string) (bool, bool) {
|
|||||||
var hasMaster bool //是否配置Master服务
|
var hasMaster bool //是否配置Master服务
|
||||||
|
|
||||||
//遍历所有结点
|
//遍历所有结点
|
||||||
for _, nodeInfo := range cls.discoveryInfo.Origin {
|
for _, nodeInfo := range cls.discoveryInfo.Origin.MasterNodeList {
|
||||||
if nodeInfo.NodeId == localNodeId {
|
if nodeInfo.NodeId == localNodeId {
|
||||||
localMaster = true
|
localMaster = true
|
||||||
}
|
}
|
||||||
@@ -485,9 +556,9 @@ func (cls *Cluster) IsOriginMasterDiscoveryNode(nodeId string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) getOriginMasterDiscoveryNodeInfo(nodeId string) *NodeInfo {
|
func (cls *Cluster) getOriginMasterDiscoveryNodeInfo(nodeId string) *NodeInfo {
|
||||||
for i := 0; i < len(cls.discoveryInfo.Origin); i++ {
|
for i := 0; i < len(cls.discoveryInfo.Origin.MasterNodeList); i++ {
|
||||||
if cls.discoveryInfo.Origin[i].NodeId == nodeId {
|
if cls.discoveryInfo.Origin.MasterNodeList[i].NodeId == nodeId {
|
||||||
return &cls.discoveryInfo.Origin[i]
|
return &cls.discoveryInfo.Origin.MasterNodeList[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ type EtcdDiscovery struct {
|
|||||||
EtcdList []EtcdList
|
EtcdList []EtcdList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OriginDiscovery struct {
|
||||||
|
TTLSecond int64
|
||||||
|
MasterNodeList []NodeInfo
|
||||||
|
}
|
||||||
|
|
||||||
type DiscoveryType int
|
type DiscoveryType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -36,7 +41,7 @@ const (
|
|||||||
type DiscoveryInfo struct {
|
type DiscoveryInfo struct {
|
||||||
discoveryType DiscoveryType
|
discoveryType DiscoveryType
|
||||||
Etcd *EtcdDiscovery //etcd
|
Etcd *EtcdDiscovery //etcd
|
||||||
Origin []NodeInfo //orign
|
Origin *OriginDiscovery //orign
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeInfoList struct {
|
type NodeInfoList struct {
|
||||||
@@ -101,8 +106,8 @@ func (d *DiscoveryInfo) setEtcd(etcd *EtcdDiscovery) error{
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DiscoveryInfo) setOrigin(nodeInfos []NodeInfo) error{
|
func (d *DiscoveryInfo) setOrigin(originDiscovery *OriginDiscovery) error{
|
||||||
if nodeInfos == nil {
|
if originDiscovery== nil || len(originDiscovery.MasterNodeList)==0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +117,7 @@ func (d *DiscoveryInfo) setOrigin(nodeInfos []NodeInfo) error{
|
|||||||
|
|
||||||
mapListenAddr := make(map[string]struct{})
|
mapListenAddr := make(map[string]struct{})
|
||||||
mapNodeId := make(map[string]struct{})
|
mapNodeId := make(map[string]struct{})
|
||||||
for _, n := range nodeInfos {
|
for _, n := range originDiscovery.MasterNodeList {
|
||||||
if _, ok := mapListenAddr[n.ListenAddr]; ok == true {
|
if _, ok := mapListenAddr[n.ListenAddr]; ok == true {
|
||||||
return fmt.Errorf("discovery config Origin.ListenAddr %s is repeat", n.ListenAddr)
|
return fmt.Errorf("discovery config Origin.ListenAddr %s is repeat", n.ListenAddr)
|
||||||
}
|
}
|
||||||
@@ -124,7 +129,7 @@ func (d *DiscoveryInfo) setOrigin(nodeInfos []NodeInfo) error{
|
|||||||
mapNodeId[n.NodeId] = struct{}{}
|
mapNodeId[n.NodeId] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Origin = nodeInfos
|
d.Origin = originDiscovery
|
||||||
d.discoveryType = OriginType
|
d.discoveryType = OriginType
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.31.0
|
||||||
// protoc v4.24.0
|
// protoc v4.24.0
|
||||||
// source: rpcproto/dynamicdiscover.proto
|
// source: rpcproto/origindiscover.proto
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ type NodeInfo struct {
|
|||||||
func (x *NodeInfo) Reset() {
|
func (x *NodeInfo) Reset() {
|
||||||
*x = NodeInfo{}
|
*x = NodeInfo{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[0]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ func (x *NodeInfo) String() string {
|
|||||||
func (*NodeInfo) ProtoMessage() {}
|
func (*NodeInfo) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *NodeInfo) ProtoReflect() protoreflect.Message {
|
func (x *NodeInfo) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[0]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -62,7 +62,7 @@ func (x *NodeInfo) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use NodeInfo.ProtoReflect.Descriptor instead.
|
// Deprecated: Use NodeInfo.ProtoReflect.Descriptor instead.
|
||||||
func (*NodeInfo) Descriptor() ([]byte, []int) {
|
func (*NodeInfo) Descriptor() ([]byte, []int) {
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescGZIP(), []int{0}
|
return file_rpcproto_origindiscover_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NodeInfo) GetNodeId() string {
|
func (x *NodeInfo) GetNodeId() string {
|
||||||
@@ -119,7 +119,7 @@ type ServiceDiscoverReq struct {
|
|||||||
func (x *ServiceDiscoverReq) Reset() {
|
func (x *ServiceDiscoverReq) Reset() {
|
||||||
*x = ServiceDiscoverReq{}
|
*x = ServiceDiscoverReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[1]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ func (x *ServiceDiscoverReq) String() string {
|
|||||||
func (*ServiceDiscoverReq) ProtoMessage() {}
|
func (*ServiceDiscoverReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *ServiceDiscoverReq) ProtoReflect() protoreflect.Message {
|
func (x *ServiceDiscoverReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[1]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -145,7 +145,7 @@ func (x *ServiceDiscoverReq) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use ServiceDiscoverReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use ServiceDiscoverReq.ProtoReflect.Descriptor instead.
|
||||||
func (*ServiceDiscoverReq) Descriptor() ([]byte, []int) {
|
func (*ServiceDiscoverReq) Descriptor() ([]byte, []int) {
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescGZIP(), []int{1}
|
return file_rpcproto_origindiscover_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *ServiceDiscoverReq) GetNodeInfo() *NodeInfo {
|
func (x *ServiceDiscoverReq) GetNodeInfo() *NodeInfo {
|
||||||
@@ -170,7 +170,7 @@ type SubscribeDiscoverNotify struct {
|
|||||||
func (x *SubscribeDiscoverNotify) Reset() {
|
func (x *SubscribeDiscoverNotify) Reset() {
|
||||||
*x = SubscribeDiscoverNotify{}
|
*x = SubscribeDiscoverNotify{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[2]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ func (x *SubscribeDiscoverNotify) String() string {
|
|||||||
func (*SubscribeDiscoverNotify) ProtoMessage() {}
|
func (*SubscribeDiscoverNotify) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *SubscribeDiscoverNotify) ProtoReflect() protoreflect.Message {
|
func (x *SubscribeDiscoverNotify) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[2]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -196,7 +196,7 @@ func (x *SubscribeDiscoverNotify) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use SubscribeDiscoverNotify.ProtoReflect.Descriptor instead.
|
// Deprecated: Use SubscribeDiscoverNotify.ProtoReflect.Descriptor instead.
|
||||||
func (*SubscribeDiscoverNotify) Descriptor() ([]byte, []int) {
|
func (*SubscribeDiscoverNotify) Descriptor() ([]byte, []int) {
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescGZIP(), []int{2}
|
return file_rpcproto_origindiscover_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *SubscribeDiscoverNotify) GetMasterNodeId() string {
|
func (x *SubscribeDiscoverNotify) GetMasterNodeId() string {
|
||||||
@@ -239,7 +239,7 @@ type NodeRetireReq struct {
|
|||||||
func (x *NodeRetireReq) Reset() {
|
func (x *NodeRetireReq) Reset() {
|
||||||
*x = NodeRetireReq{}
|
*x = NodeRetireReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[3]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ func (x *NodeRetireReq) String() string {
|
|||||||
func (*NodeRetireReq) ProtoMessage() {}
|
func (*NodeRetireReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *NodeRetireReq) ProtoReflect() protoreflect.Message {
|
func (x *NodeRetireReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[3]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -265,7 +265,7 @@ func (x *NodeRetireReq) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use NodeRetireReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use NodeRetireReq.ProtoReflect.Descriptor instead.
|
||||||
func (*NodeRetireReq) Descriptor() ([]byte, []int) {
|
func (*NodeRetireReq) Descriptor() ([]byte, []int) {
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescGZIP(), []int{3}
|
return file_rpcproto_origindiscover_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *NodeRetireReq) GetNodeInfo() *NodeInfo {
|
func (x *NodeRetireReq) GetNodeInfo() *NodeInfo {
|
||||||
@@ -285,7 +285,7 @@ type Empty struct {
|
|||||||
func (x *Empty) Reset() {
|
func (x *Empty) Reset() {
|
||||||
*x = Empty{}
|
*x = Empty{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[4]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ func (x *Empty) String() string {
|
|||||||
func (*Empty) ProtoMessage() {}
|
func (*Empty) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *Empty) ProtoReflect() protoreflect.Message {
|
func (x *Empty) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_rpcproto_dynamicdiscover_proto_msgTypes[4]
|
mi := &file_rpcproto_origindiscover_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -311,70 +311,70 @@ func (x *Empty) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
|
||||||
func (*Empty) Descriptor() ([]byte, []int) {
|
func (*Empty) Descriptor() ([]byte, []int) {
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescGZIP(), []int{4}
|
return file_rpcproto_origindiscover_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_rpcproto_dynamicdiscover_proto protoreflect.FileDescriptor
|
var File_rpcproto_origindiscover_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_rpcproto_dynamicdiscover_proto_rawDesc = []byte{
|
var file_rpcproto_origindiscover_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1e, 0x72, 0x70, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x64, 0x79, 0x6e, 0x61, 0x6d,
|
0x0a, 0x1d, 0x72, 0x70, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x72, 0x69, 0x67, 0x69,
|
||||||
0x69, 0x63, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x6e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||||
0x12, 0x03, 0x72, 0x70, 0x63, 0x22, 0xca, 0x01, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e,
|
0x03, 0x72, 0x70, 0x63, 0x22, 0xca, 0x01, 0x0a, 0x08, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66,
|
||||||
0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x6f, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x28, 0x09, 0x52, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x4c, 0x69,
|
0x09, 0x52, 0x06, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x4c, 0x69, 0x73,
|
||||||
0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x4c,
|
||||||
0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x4d, 0x61,
|
0x69, 0x73, 0x74, 0x65, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x4d, 0x61, 0x78,
|
||||||
0x78, 0x52, 0x70, 0x63, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01,
|
0x52, 0x70, 0x63, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4c, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||||
0x28, 0x0d, 0x52, 0x0e, 0x4d, 0x61, 0x78, 0x52, 0x70, 0x63, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4c,
|
0x0d, 0x52, 0x0e, 0x4d, 0x61, 0x78, 0x52, 0x70, 0x63, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4c, 0x65,
|
||||||
0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20,
|
0x6e, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01,
|
||||||
0x01, 0x28, 0x08, 0x52, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
0x28, 0x08, 0x52, 0x07, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x52,
|
||||||
0x52, 0x65, 0x74, 0x69, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65,
|
0x65, 0x74, 0x69, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x74,
|
||||||
0x74, 0x69, 0x72, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65,
|
0x69, 0x72, 0x65, 0x12, 0x2c, 0x0a, 0x11, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65, 0x72,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52,
|
0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11,
|
||||||
0x11, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69,
|
0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4c, 0x69, 0x73,
|
||||||
0x73, 0x74, 0x22, 0x3f, 0x0a, 0x12, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73,
|
0x74, 0x22, 0x3f, 0x0a, 0x12, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63,
|
||||||
0x63, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65,
|
0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49,
|
||||||
0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63,
|
0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e,
|
||||||
|
0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e,
|
||||||
|
0x66, 0x6f, 0x22, 0x9e, 0x01, 0x0a, 0x17, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65,
|
||||||
|
0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x22,
|
||||||
|
0x0a, 0x0c, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x01,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65,
|
||||||
|
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x18, 0x02, 0x20, 0x01,
|
||||||
|
0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x44, 0x65,
|
||||||
|
0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x44,
|
||||||
|
0x65, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65,
|
||||||
|
0x49, 0x6e, 0x66, 0x6f, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63,
|
||||||
0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49,
|
0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49,
|
||||||
0x6e, 0x66, 0x6f, 0x22, 0x9e, 0x01, 0x0a, 0x17, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
|
0x6e, 0x66, 0x6f, 0x22, 0x3a, 0x0a, 0x0d, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x69, 0x72,
|
||||||
0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12,
|
0x65, 0x52, 0x65, 0x71, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f,
|
||||||
0x22, 0x0a, 0x0c, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4e, 0x6f, 0x64,
|
||||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x6f, 0x64,
|
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22,
|
||||||
0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x18, 0x02, 0x20,
|
0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x72, 0x70,
|
||||||
0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x46, 0x75, 0x6c, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x44,
|
0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x65, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
|
||||||
0x44, 0x65, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64,
|
|
||||||
0x65, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70,
|
|
||||||
0x63, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65,
|
|
||||||
0x49, 0x6e, 0x66, 0x6f, 0x22, 0x3a, 0x0a, 0x0d, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x69,
|
|
||||||
0x72, 0x65, 0x52, 0x65, 0x71, 0x12, 0x29, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66,
|
|
||||||
0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4e, 0x6f,
|
|
||||||
0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f,
|
|
||||||
0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x72,
|
|
||||||
0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_rpcproto_dynamicdiscover_proto_rawDescOnce sync.Once
|
file_rpcproto_origindiscover_proto_rawDescOnce sync.Once
|
||||||
file_rpcproto_dynamicdiscover_proto_rawDescData = file_rpcproto_dynamicdiscover_proto_rawDesc
|
file_rpcproto_origindiscover_proto_rawDescData = file_rpcproto_origindiscover_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_rpcproto_dynamicdiscover_proto_rawDescGZIP() []byte {
|
func file_rpcproto_origindiscover_proto_rawDescGZIP() []byte {
|
||||||
file_rpcproto_dynamicdiscover_proto_rawDescOnce.Do(func() {
|
file_rpcproto_origindiscover_proto_rawDescOnce.Do(func() {
|
||||||
file_rpcproto_dynamicdiscover_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpcproto_dynamicdiscover_proto_rawDescData)
|
file_rpcproto_origindiscover_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpcproto_origindiscover_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_rpcproto_dynamicdiscover_proto_rawDescData
|
return file_rpcproto_origindiscover_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_rpcproto_dynamicdiscover_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
var file_rpcproto_origindiscover_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||||
var file_rpcproto_dynamicdiscover_proto_goTypes = []interface{}{
|
var file_rpcproto_origindiscover_proto_goTypes = []interface{}{
|
||||||
(*NodeInfo)(nil), // 0: rpc.NodeInfo
|
(*NodeInfo)(nil), // 0: rpc.NodeInfo
|
||||||
(*ServiceDiscoverReq)(nil), // 1: rpc.ServiceDiscoverReq
|
(*ServiceDiscoverReq)(nil), // 1: rpc.ServiceDiscoverReq
|
||||||
(*SubscribeDiscoverNotify)(nil), // 2: rpc.SubscribeDiscoverNotify
|
(*SubscribeDiscoverNotify)(nil), // 2: rpc.SubscribeDiscoverNotify
|
||||||
(*NodeRetireReq)(nil), // 3: rpc.NodeRetireReq
|
(*NodeRetireReq)(nil), // 3: rpc.NodeRetireReq
|
||||||
(*Empty)(nil), // 4: rpc.Empty
|
(*Empty)(nil), // 4: rpc.Empty
|
||||||
}
|
}
|
||||||
var file_rpcproto_dynamicdiscover_proto_depIdxs = []int32{
|
var file_rpcproto_origindiscover_proto_depIdxs = []int32{
|
||||||
0, // 0: rpc.ServiceDiscoverReq.nodeInfo:type_name -> rpc.NodeInfo
|
0, // 0: rpc.ServiceDiscoverReq.nodeInfo:type_name -> rpc.NodeInfo
|
||||||
0, // 1: rpc.SubscribeDiscoverNotify.nodeInfo:type_name -> rpc.NodeInfo
|
0, // 1: rpc.SubscribeDiscoverNotify.nodeInfo:type_name -> rpc.NodeInfo
|
||||||
0, // 2: rpc.NodeRetireReq.nodeInfo:type_name -> rpc.NodeInfo
|
0, // 2: rpc.NodeRetireReq.nodeInfo:type_name -> rpc.NodeInfo
|
||||||
@@ -385,13 +385,13 @@ var file_rpcproto_dynamicdiscover_proto_depIdxs = []int32{
|
|||||||
0, // [0:3] is the sub-list for field type_name
|
0, // [0:3] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_rpcproto_dynamicdiscover_proto_init() }
|
func init() { file_rpcproto_origindiscover_proto_init() }
|
||||||
func file_rpcproto_dynamicdiscover_proto_init() {
|
func file_rpcproto_origindiscover_proto_init() {
|
||||||
if File_rpcproto_dynamicdiscover_proto != nil {
|
if File_rpcproto_origindiscover_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_rpcproto_dynamicdiscover_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_origindiscover_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*NodeInfo); i {
|
switch v := v.(*NodeInfo); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -403,7 +403,7 @@ func file_rpcproto_dynamicdiscover_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_rpcproto_dynamicdiscover_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_origindiscover_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*ServiceDiscoverReq); i {
|
switch v := v.(*ServiceDiscoverReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -415,7 +415,7 @@ func file_rpcproto_dynamicdiscover_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_rpcproto_dynamicdiscover_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_origindiscover_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*SubscribeDiscoverNotify); i {
|
switch v := v.(*SubscribeDiscoverNotify); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -427,7 +427,7 @@ func file_rpcproto_dynamicdiscover_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_rpcproto_dynamicdiscover_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_origindiscover_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*NodeRetireReq); i {
|
switch v := v.(*NodeRetireReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -439,7 +439,7 @@ func file_rpcproto_dynamicdiscover_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_rpcproto_dynamicdiscover_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_origindiscover_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*Empty); i {
|
switch v := v.(*Empty); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -456,18 +456,18 @@ func file_rpcproto_dynamicdiscover_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_rpcproto_dynamicdiscover_proto_rawDesc,
|
RawDescriptor: file_rpcproto_origindiscover_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 5,
|
NumMessages: 5,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_rpcproto_dynamicdiscover_proto_goTypes,
|
GoTypes: file_rpcproto_origindiscover_proto_goTypes,
|
||||||
DependencyIndexes: file_rpcproto_dynamicdiscover_proto_depIdxs,
|
DependencyIndexes: file_rpcproto_origindiscover_proto_depIdxs,
|
||||||
MessageInfos: file_rpcproto_dynamicdiscover_proto_msgTypes,
|
MessageInfos: file_rpcproto_origindiscover_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_rpcproto_dynamicdiscover_proto = out.File
|
File_rpcproto_origindiscover_proto = out.File
|
||||||
file_rpcproto_dynamicdiscover_proto_rawDesc = nil
|
file_rpcproto_origindiscover_proto_rawDesc = nil
|
||||||
file_rpcproto_dynamicdiscover_proto_goTypes = nil
|
file_rpcproto_origindiscover_proto_goTypes = nil
|
||||||
file_rpcproto_dynamicdiscover_proto_depIdxs = nil
|
file_rpcproto_origindiscover_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
@@ -77,6 +77,17 @@ type DiscoveryServiceEvent struct{
|
|||||||
NodeId string
|
NodeId string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EtcdServiceRecordEvent struct {
|
||||||
|
NetworkName string
|
||||||
|
TTLSecond int64
|
||||||
|
RecordKey string
|
||||||
|
RecordInfo string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Empty struct {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func SetMaxServiceChannel(maxEventChannel int){
|
func SetMaxServiceChannel(maxEventChannel int){
|
||||||
maxServiceEventChannelNum = maxEventChannel
|
maxServiceEventChannelNum = maxEventChannel
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user