mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
新增私有服务功能(结点中服务配置加前缀_)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cluster
|
||||
|
||||
import "strings"
|
||||
|
||||
type ConfigDiscovery struct {
|
||||
funDelService FunDelNode
|
||||
@@ -7,6 +8,17 @@ type ConfigDiscovery struct {
|
||||
localNodeId int
|
||||
}
|
||||
|
||||
func (discovery *ConfigDiscovery) privateService(nodeInfo *NodeInfo){
|
||||
var serviceList []string
|
||||
for _,s := range nodeInfo.ServiceList {
|
||||
if strings.HasPrefix(s,"_") {
|
||||
continue
|
||||
}
|
||||
serviceList = append(serviceList,s)
|
||||
}
|
||||
nodeInfo.ServiceList = serviceList
|
||||
}
|
||||
|
||||
func (discovery *ConfigDiscovery) Init(localNodeId int) error{
|
||||
discovery.localNodeId = localNodeId
|
||||
|
||||
@@ -20,6 +32,8 @@ func (discovery *ConfigDiscovery) Init(localNodeId int) error{
|
||||
if nodeInfo.NodeId == localNodeId {
|
||||
continue
|
||||
}
|
||||
//去除私有服务
|
||||
discovery.privateService(&nodeInfo)
|
||||
discovery.funSetService(&nodeInfo)
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,12 @@ func (cls *Cluster) parseLocalCfg(){
|
||||
}
|
||||
}
|
||||
|
||||
func (cls *Cluster) localPrivateService(localNodeInfo *NodeInfo){
|
||||
for i:=0;i<len(localNodeInfo.ServiceList);i++{
|
||||
localNodeInfo.ServiceList[i] = strings.TrimLeft(localNodeInfo.ServiceList[i],"_")
|
||||
}
|
||||
}
|
||||
|
||||
func (cls *Cluster) InitCfg(localNodeId int) error{
|
||||
cls.localServiceCfg = map[string]interface{}{}
|
||||
cls.mapRpc = map[int] NodeRpcInfo{}
|
||||
@@ -158,6 +164,7 @@ func (cls *Cluster) InitCfg(localNodeId int) error{
|
||||
return err
|
||||
}
|
||||
cls.localNodeInfo = nodeInfoList[0]
|
||||
cls.localPrivateService(&cls.localNodeInfo)
|
||||
|
||||
//读取本地服务配置
|
||||
err = cls.readLocalService(localNodeId)
|
||||
|
||||
Reference in New Issue
Block a user