Documentation ¶
Index ¶
- Constants
- func GetNodeByServiceName(serviceName string) map[string]struct{}
- func GetNodeByTemplateServiceName(templateServiceName string) map[string]string
- func GetNodeIdByTemplateService(templateServiceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client)
- func GetRpcClient(nodeId string, serviceMethod string, filterRetire bool, ...) (error, []*rpc.Client)
- func GetRpcServer() rpc.IServer
- func HasService(nodeId string, serviceName string) bool
- func SetConfigDir(cfgDir string)
- func SetServiceDiscovery(serviceDiscovery IServiceDiscovery)
- type Cluster
- func (cls *Cluster) AddDiscoveryService(serviceName string, bPublicService bool)
- func (cls *Cluster) CanDiscoveryService(fromMasterNodeId string, serviceName string) bool
- func (cls *Cluster) DelNode(nodeId string)
- func (cls *Cluster) DiscardNode(nodeId string)
- func (cls *Cluster) FindRpcHandler(serviceName string) rpc.IRpcHandler
- func (cls *Cluster) GetEtcdDiscovery() *EtcdDiscovery
- func (cls *Cluster) GetGlobalCfg() interface{}
- func (cls *Cluster) GetLocalNodeInfo() *NodeInfo
- func (cls *Cluster) GetNatsUrl() string
- func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client)
- func (cls *Cluster) GetNodeIdByTemplateService(templateServiceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client)
- func (cls *Cluster) GetNodeInfo(nodeId string) (NodeInfo, bool)
- func (cls *Cluster) GetOriginDiscovery() *OriginDiscovery
- func (cls *Cluster) GetRpcClient(nodeId string) (*rpc.Client, bool)
- func (cls *Cluster) GetServiceCfg(serviceName string) interface{}
- func (cls *Cluster) Init(localNodeId string, setupServiceFun SetupServiceFun) error
- func (cls *Cluster) InitCfg(localNodeId string) error
- func (cls *Cluster) IsConfigService(serviceName string) bool
- func (cls *Cluster) IsNatsMode() bool
- func (cls *Cluster) IsNodeConnected(nodeId string) bool
- func (cls *Cluster) IsNodeRetire(nodeId string) bool
- func (cls *Cluster) IsOriginMasterDiscoveryNode(nodeId string) bool
- func (cls *Cluster) NotifyAllService(event event.IEvent)
- func (cls *Cluster) ParseGlobalCfg(cfg interface{}) error
- func (cls *Cluster) ReadClusterConfig(filepath string) (*NodeInfoList, error)
- func (cls *Cluster) RegRpcEvent(serviceName string)
- func (cls *Cluster) SetRpcMode(cfgRpcMode *RpcMode, rpcMode *RpcMode) error
- func (cls *Cluster) Start() error
- func (cls *Cluster) Stop()
- func (cls *Cluster) TriggerDiscoveryEvent(bDiscovery bool, nodeId string, serviceName []string)
- func (cls *Cluster) UnRegRpcEvent(serviceName string)
- type ConfigDiscovery
- type DiscoveryInfo
- type DiscoveryService
- type DiscoveryType
- type EtcdDiscovery
- type EtcdDiscoveryService
- func (ed *EtcdDiscoveryService) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
- func (ed *EtcdDiscoveryService) OnEtcdDiscovery(ev event.IEvent)
- func (ed *EtcdDiscoveryService) OnEventDelete(watchKey string, Kv *mvccpb.KeyValue)
- func (ed *EtcdDiscoveryService) OnEventGets(watchKey string, Kvs []*mvccpb.KeyValue)
- func (ed *EtcdDiscoveryService) OnEventPut(watchKey string, Kv *mvccpb.KeyValue)
- func (ed *EtcdDiscoveryService) OnInit() error
- func (ed *EtcdDiscoveryService) OnNodeDisconnect(nodeId string)
- func (ed *EtcdDiscoveryService) OnRelease()
- func (ed *EtcdDiscoveryService) OnRetire()
- func (ed *EtcdDiscoveryService) OnStart()
- func (ed *EtcdDiscoveryService) RPC_ServiceRecord(etcdServiceRecord *service.EtcdServiceRecordEvent, empty *service.Empty) error
- type EtcdList
- type FunDelNode
- type FunSetNode
- type IServiceDiscovery
- type NatsConfig
- type NodeInfo
- type NodeInfoList
- type NodeRpcInfo
- type NodeStatus
- type OperType
- type OriginDiscovery
- type OriginDiscoveryClient
- func (dc *OriginDiscoveryClient) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
- func (dc *OriginDiscoveryClient) OnInit() error
- func (dc *OriginDiscoveryClient) OnNatsConnected()
- func (dc *OriginDiscoveryClient) OnNatsDisconnect()
- func (dc *OriginDiscoveryClient) OnNodeConnected(nodeId string)
- func (dc *OriginDiscoveryClient) OnNodeDisconnect(nodeId string)
- func (dc *OriginDiscoveryClient) OnRelease()
- func (dc *OriginDiscoveryClient) OnRetire()
- func (dc *OriginDiscoveryClient) OnStart()
- func (dc *OriginDiscoveryClient) RPC_SubServiceDiscover(req *rpc.SubscribeDiscoverNotify) error
- type OriginDiscoveryMaster
- func (ds *OriginDiscoveryMaster) OnInit() error
- func (ds *OriginDiscoveryMaster) OnNatsConnected()
- func (ds *OriginDiscoveryMaster) OnNatsDisconnect()
- func (ds *OriginDiscoveryMaster) OnNodeConnected(nodeId string)
- func (ds *OriginDiscoveryMaster) OnNodeDisconnect(nodeId string)
- func (ds *OriginDiscoveryMaster) OnStart()
- func (ds *OriginDiscoveryMaster) RPC_NodeRetire(req *rpc.NodeRetireReq, _ *rpc.Empty) error
- func (ds *OriginDiscoveryMaster) RPC_Ping(req *rpc.Ping, res *rpc.Pong) error
- func (ds *OriginDiscoveryMaster) RPC_RegServiceDiscover(req *rpc.RegServiceDiscoverReq, res *rpc.SubscribeDiscoverNotify) error
- func (ds *OriginDiscoveryMaster) RPC_UnRegServiceDiscover(req *rpc.UnRegServiceDiscoverReq, _ *rpc.Empty) error
- func (ds *OriginDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{})
- type RpcMode
- type SetupServiceFun
Constants ¶
View Source
const ( InvalidType = 0 OriginType = 1 EtcdType = 2 )
View Source
const MinTTL = 3
View Source
const NodeRetireRpcMethod = OriginDiscoveryMasterName + ".RPC_NodeRetire"
View Source
const OriginDiscoveryClientName = "DiscoveryClient"
View Source
const OriginDiscoveryMasterName = "DiscoveryMaster"
View Source
const RegServiceDiscover = OriginDiscoveryMasterName + ".RPC_RegServiceDiscover"
View Source
const RpcPingMethod = OriginDiscoveryMasterName + ".RPC_Ping"
View Source
const SubServiceDiscover = OriginDiscoveryClientName + ".RPC_SubServiceDiscover"
View Source
const UnRegServiceDiscover = OriginDiscoveryMasterName + ".RPC_UnRegServiceDiscover"
Variables ¶
This section is empty.
Functions ¶
func GetNodeByServiceName ¶
func GetNodeByTemplateServiceName ¶ added in v2.0.6
GetNodeByTemplateServiceName 通过模板服务名获取服务名,返回 map[serviceName真实服务名]NodeId
func GetNodeIdByTemplateService ¶ added in v2.0.6
func GetRpcClient ¶
func GetRpcServer ¶
func HasService ¶
func SetConfigDir ¶
func SetConfigDir(cfgDir string)
func SetServiceDiscovery ¶
func SetServiceDiscovery(serviceDiscovery IServiceDiscovery)
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func GetCluster ¶
func GetCluster() *Cluster
func (*Cluster) AddDiscoveryService ¶ added in v2.0.1
func (*Cluster) CanDiscoveryService ¶ added in v2.0.1
func (*Cluster) DiscardNode ¶
func (*Cluster) FindRpcHandler ¶
func (cls *Cluster) FindRpcHandler(serviceName string) rpc.IRpcHandler
func (*Cluster) GetEtcdDiscovery ¶ added in v2.0.1
func (cls *Cluster) GetEtcdDiscovery() *EtcdDiscovery
func (*Cluster) GetGlobalCfg ¶
func (cls *Cluster) GetGlobalCfg() interface{}
func (*Cluster) GetLocalNodeInfo ¶
func (*Cluster) GetNatsUrl ¶ added in v2.0.1
func (*Cluster) GetNodeIdByService ¶
func (*Cluster) GetNodeIdByTemplateService ¶ added in v2.0.6
func (*Cluster) GetOriginDiscovery ¶ added in v2.0.1
func (cls *Cluster) GetOriginDiscovery() *OriginDiscovery
func (*Cluster) GetServiceCfg ¶
func (*Cluster) Init ¶
func (cls *Cluster) Init(localNodeId string, setupServiceFun SetupServiceFun) error
func (*Cluster) IsConfigService ¶
func (*Cluster) IsNatsMode ¶ added in v2.0.1
func (*Cluster) IsNodeConnected ¶
func (*Cluster) IsNodeRetire ¶
func (*Cluster) IsOriginMasterDiscoveryNode ¶ added in v2.0.1
func (*Cluster) NotifyAllService ¶ added in v2.0.1
func (*Cluster) ParseGlobalCfg ¶ added in v2.0.7
func (*Cluster) ReadClusterConfig ¶
func (cls *Cluster) ReadClusterConfig(filepath string) (*NodeInfoList, error)
func (*Cluster) RegRpcEvent ¶
func (*Cluster) SetRpcMode ¶ added in v2.0.1
func (*Cluster) TriggerDiscoveryEvent ¶
func (*Cluster) UnRegRpcEvent ¶
type ConfigDiscovery ¶
type ConfigDiscovery struct {
// contains filtered or unexported fields
}
func (*ConfigDiscovery) InitDiscovery ¶
func (discovery *ConfigDiscovery) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
type DiscoveryInfo ¶ added in v2.0.1
type DiscoveryInfo struct { Etcd *EtcdDiscovery //etcd Origin *OriginDiscovery //origin // contains filtered or unexported fields }
type DiscoveryService ¶ added in v2.0.1
type DiscoveryType ¶ added in v2.0.1
type DiscoveryType int
type EtcdDiscovery ¶ added in v2.0.1
type EtcdDiscoveryService ¶ added in v2.0.1
func (*EtcdDiscoveryService) InitDiscovery ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
func (*EtcdDiscoveryService) OnEtcdDiscovery ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnEtcdDiscovery(ev event.IEvent)
func (*EtcdDiscoveryService) OnEventDelete ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnEventDelete(watchKey string, Kv *mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnEventGets ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnEventGets(watchKey string, Kvs []*mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnEventPut ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnEventPut(watchKey string, Kv *mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnInit ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnInit() error
func (*EtcdDiscoveryService) OnNodeDisconnect ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnNodeDisconnect(nodeId string)
func (*EtcdDiscoveryService) OnRelease ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnRelease()
func (*EtcdDiscoveryService) OnRetire ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnRetire()
func (*EtcdDiscoveryService) OnStart ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) OnStart()
func (*EtcdDiscoveryService) RPC_ServiceRecord ¶ added in v2.0.1
func (ed *EtcdDiscoveryService) RPC_ServiceRecord(etcdServiceRecord *service.EtcdServiceRecordEvent, empty *service.Empty) error
type FunDelNode ¶
type FunDelNode func(nodeId string)
type FunSetNode ¶ added in v2.0.1
type FunSetNode func(nodeInfo *NodeInfo)
type IServiceDiscovery ¶
type IServiceDiscovery interface {
InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNodeInfo FunSetNode) error
}
type NatsConfig ¶ added in v2.0.1
type NodeInfo ¶
type NodeInfo struct { NodeId string Private bool ListenAddr string MaxRpcParamLen uint32 //最大Rpc参数长度 CompressBytesLen int //超过字节进行压缩的长度 ServiceList []string //所有的有序服务列表 PublicServiceList []string //对外公开的服务列表 DiscoveryService []DiscoveryService //筛选发现的服务,如果不配置,不进行筛选 Retire bool NetworkName string // contains filtered or unexported fields }
type NodeInfoList ¶
type NodeInfoList struct { RpcMode RpcMode Discovery DiscoveryInfo NodeList []NodeInfo }
type NodeRpcInfo ¶
type NodeRpcInfo struct {
// contains filtered or unexported fields
}
type NodeStatus ¶
type NodeStatus int
const ( Normal NodeStatus = 0 //正常 Discard NodeStatus = 1 //丢弃 )
type OriginDiscovery ¶ added in v2.0.1
type OriginDiscoveryClient ¶ added in v2.0.1
func (*OriginDiscoveryClient) InitDiscovery ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
func (*OriginDiscoveryClient) OnInit ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnInit() error
func (*OriginDiscoveryClient) OnNatsConnected ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnNatsConnected()
func (*OriginDiscoveryClient) OnNatsDisconnect ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnNatsDisconnect()
func (*OriginDiscoveryClient) OnNodeConnected ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnNodeConnected(nodeId string)
func (*OriginDiscoveryClient) OnNodeDisconnect ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnNodeDisconnect(nodeId string)
func (*OriginDiscoveryClient) OnRelease ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnRelease()
func (*OriginDiscoveryClient) OnRetire ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnRetire()
func (*OriginDiscoveryClient) OnStart ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) OnStart()
func (*OriginDiscoveryClient) RPC_SubServiceDiscover ¶ added in v2.0.1
func (dc *OriginDiscoveryClient) RPC_SubServiceDiscover(req *rpc.SubscribeDiscoverNotify) error
RPC_SubServiceDiscover 订阅发现的服务通知
type OriginDiscoveryMaster ¶ added in v2.0.1
func (*OriginDiscoveryMaster) OnInit ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnInit() error
func (*OriginDiscoveryMaster) OnNatsConnected ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnNatsConnected()
func (*OriginDiscoveryMaster) OnNatsDisconnect ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnNatsDisconnect()
func (*OriginDiscoveryMaster) OnNodeConnected ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnNodeConnected(nodeId string)
func (*OriginDiscoveryMaster) OnNodeDisconnect ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnNodeDisconnect(nodeId string)
func (*OriginDiscoveryMaster) OnStart ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) OnStart()
func (*OriginDiscoveryMaster) RPC_NodeRetire ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) RPC_NodeRetire(req *rpc.NodeRetireReq, _ *rpc.Empty) error
func (*OriginDiscoveryMaster) RPC_RegServiceDiscover ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) RPC_RegServiceDiscover(req *rpc.RegServiceDiscoverReq, res *rpc.SubscribeDiscoverNotify) error
收到注册过来的结点
func (*OriginDiscoveryMaster) RPC_UnRegServiceDiscover ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) RPC_UnRegServiceDiscover(req *rpc.UnRegServiceDiscoverReq, _ *rpc.Empty) error
func (*OriginDiscoveryMaster) RpcCastGo ¶ added in v2.0.1
func (ds *OriginDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{})
type RpcMode ¶ added in v2.0.1
type RpcMode struct { Typ string `json:"Type"` Nats NatsConfig }
type SetupServiceFun ¶
Click to show internal directories.
Click to hide internal directories.