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 LogConfig
- 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 ¶
GetNodeByTemplateServiceName 通过模板服务名获取服务名,返回 map[serviceName真实服务名]NodeId
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 ¶
func (*Cluster) CanDiscoveryService ¶
func (*Cluster) DiscardNode ¶
func (*Cluster) FindRpcHandler ¶
func (cls *Cluster) FindRpcHandler(serviceName string) rpc.IRpcHandler
func (*Cluster) GetEtcdDiscovery ¶
func (cls *Cluster) GetEtcdDiscovery() *EtcdDiscovery
func (*Cluster) GetGlobalCfg ¶
func (cls *Cluster) GetGlobalCfg() interface{}
func (*Cluster) GetLocalNodeInfo ¶
func (*Cluster) GetNatsUrl ¶
func (*Cluster) GetNodeIdByService ¶
func (*Cluster) GetNodeIdByTemplateService ¶
func (*Cluster) GetOriginDiscovery ¶
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 ¶
func (*Cluster) IsNodeConnected ¶
func (*Cluster) IsNodeRetire ¶
func (*Cluster) IsOriginMasterDiscoveryNode ¶
func (*Cluster) NotifyAllService ¶
func (*Cluster) ParseGlobalCfg ¶
func (*Cluster) ReadClusterConfig ¶
func (cls *Cluster) ReadClusterConfig(filepath string) (*NodeInfoList, error)
func (*Cluster) RegRpcEvent ¶
func (*Cluster) SetRpcMode ¶
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 ¶
type DiscoveryInfo struct { Etcd *EtcdDiscovery //etcd Origin *OriginDiscovery //origin // contains filtered or unexported fields }
type DiscoveryService ¶
type DiscoveryType ¶
type DiscoveryType int
type EtcdDiscovery ¶
type EtcdDiscoveryService ¶
func (*EtcdDiscoveryService) InitDiscovery ¶
func (ed *EtcdDiscoveryService) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
func (*EtcdDiscoveryService) OnEtcdDiscovery ¶
func (ed *EtcdDiscoveryService) OnEtcdDiscovery(ev event.IEvent)
func (*EtcdDiscoveryService) OnEventDelete ¶
func (ed *EtcdDiscoveryService) OnEventDelete(watchKey string, Kv *mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnEventGets ¶
func (ed *EtcdDiscoveryService) OnEventGets(watchKey string, Kvs []*mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnEventPut ¶
func (ed *EtcdDiscoveryService) OnEventPut(watchKey string, Kv *mvccpb.KeyValue)
func (*EtcdDiscoveryService) OnInit ¶
func (ed *EtcdDiscoveryService) OnInit() error
func (*EtcdDiscoveryService) OnNodeDisconnect ¶
func (ed *EtcdDiscoveryService) OnNodeDisconnect(nodeId string)
func (*EtcdDiscoveryService) OnRelease ¶
func (ed *EtcdDiscoveryService) OnRelease()
func (*EtcdDiscoveryService) OnRetire ¶
func (ed *EtcdDiscoveryService) OnRetire()
func (*EtcdDiscoveryService) OnStart ¶
func (ed *EtcdDiscoveryService) OnStart()
func (*EtcdDiscoveryService) RPC_ServiceRecord ¶
func (ed *EtcdDiscoveryService) RPC_ServiceRecord(etcdServiceRecord *service.EtcdServiceRecordEvent, empty *service.Empty) error
type FunDelNode ¶
type FunDelNode func(nodeId string)
type FunSetNode ¶
type FunSetNode func(nodeInfo *NodeInfo)
type IServiceDiscovery ¶
type IServiceDiscovery interface {
InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNodeInfo FunSetNode) error
}
type LogConfig ¶
type LogConfig struct { Encoder string //日志编码方式 console|json 默认console Level string //日志级别 debug|info|warning|error|fatal 默认console OutputType string //日志输出方式 console|file|all 默认all (console:只输出到控制台,file:只输出到文件,all:即输出到控制台也输出到文件) Path string //文件日志输出的目录 默认 ./log FlieSize int //文件最大日志大小(Mb级别) 默认 100 }
type NatsConfig ¶
type NodeInfo ¶
type NodeInfo struct { NodeId string Private bool ListenAddr string MaxRpcParamLen uint32 //最大Rpc参数长度 CompressBytesLen int //超过字节进行压缩的长度 ServiceList []string //所有的有序服务列表 PublicServiceList []string //对外公开的服务列表 DiscoveryService []DiscoveryService //筛选发现的服务,如果不配置,不进行筛选 LogCfg LogConfig //节点日志相关配置 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 ¶
type OriginDiscoveryClient ¶
func (*OriginDiscoveryClient) InitDiscovery ¶
func (dc *OriginDiscoveryClient) InitDiscovery(localNodeId string, funDelNode FunDelNode, funSetNode FunSetNode) error
func (*OriginDiscoveryClient) OnInit ¶
func (dc *OriginDiscoveryClient) OnInit() error
func (*OriginDiscoveryClient) OnNatsConnected ¶
func (dc *OriginDiscoveryClient) OnNatsConnected()
func (*OriginDiscoveryClient) OnNatsDisconnect ¶
func (dc *OriginDiscoveryClient) OnNatsDisconnect()
func (*OriginDiscoveryClient) OnNodeConnected ¶
func (dc *OriginDiscoveryClient) OnNodeConnected(nodeId string)
func (*OriginDiscoveryClient) OnNodeDisconnect ¶
func (dc *OriginDiscoveryClient) OnNodeDisconnect(nodeId string)
func (*OriginDiscoveryClient) OnRelease ¶
func (dc *OriginDiscoveryClient) OnRelease()
func (*OriginDiscoveryClient) OnRetire ¶
func (dc *OriginDiscoveryClient) OnRetire()
func (*OriginDiscoveryClient) OnStart ¶
func (dc *OriginDiscoveryClient) OnStart()
func (*OriginDiscoveryClient) RPC_SubServiceDiscover ¶
func (dc *OriginDiscoveryClient) RPC_SubServiceDiscover(req *rpc.SubscribeDiscoverNotify) error
RPC_SubServiceDiscover 订阅发现的服务通知
type OriginDiscoveryMaster ¶
func (*OriginDiscoveryMaster) OnInit ¶
func (ds *OriginDiscoveryMaster) OnInit() error
func (*OriginDiscoveryMaster) OnNatsConnected ¶
func (ds *OriginDiscoveryMaster) OnNatsConnected()
func (*OriginDiscoveryMaster) OnNatsDisconnect ¶
func (ds *OriginDiscoveryMaster) OnNatsDisconnect()
func (*OriginDiscoveryMaster) OnNodeConnected ¶
func (ds *OriginDiscoveryMaster) OnNodeConnected(nodeId string)
func (*OriginDiscoveryMaster) OnNodeDisconnect ¶
func (ds *OriginDiscoveryMaster) OnNodeDisconnect(nodeId string)
func (*OriginDiscoveryMaster) OnStart ¶
func (ds *OriginDiscoveryMaster) OnStart()
func (*OriginDiscoveryMaster) RPC_NodeRetire ¶
func (ds *OriginDiscoveryMaster) RPC_NodeRetire(req *rpc.NodeRetireReq, _ *rpc.Empty) error
func (*OriginDiscoveryMaster) RPC_RegServiceDiscover ¶
func (ds *OriginDiscoveryMaster) RPC_RegServiceDiscover(req *rpc.RegServiceDiscoverReq, res *rpc.SubscribeDiscoverNotify) error
收到注册过来的结点
func (*OriginDiscoveryMaster) RPC_UnRegServiceDiscover ¶
func (ds *OriginDiscoveryMaster) RPC_UnRegServiceDiscover(req *rpc.UnRegServiceDiscoverReq, _ *rpc.Empty) error
func (*OriginDiscoveryMaster) RpcCastGo ¶
func (ds *OriginDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{})
type RpcMode ¶
type RpcMode struct { Typ string `json:"Type"` Nats NatsConfig }
type SetupServiceFun ¶
Click to show internal directories.
Click to hide internal directories.