cluster

package
v0.0.0-...-1905027 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AddSubServiceDiscover = DynamicDiscoveryMasterName + ".RPC_AddSubServiceDiscover"
View Source
const DynamicDiscoveryClientName = "DiscoveryClient"
View Source
const DynamicDiscoveryMasterName = "DiscoveryMaster"
View Source
const RegServiceDiscover = DynamicDiscoveryMasterName + ".RPC_RegServiceDiscover"
View Source
const SubServiceDiscover = DynamicDiscoveryClientName + ".RPC_SubServiceDiscover"

Variables

This section is empty.

Functions

func GetNodeByServiceName

func GetNodeByServiceName(serviceName string) map[int]struct{}

func GetRpcClient

func GetRpcClient(nodeId int, serviceMethod string, clientList []*rpc.Client) (error, int)

func GetRpcServer

func GetRpcServer() *rpc.Server

func HasService

func HasService(nodeId int, serviceName string) bool

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) AddDynamicDiscoveryService

func (cls *Cluster) AddDynamicDiscoveryService(serviceName string, bPublicService bool)

func (*Cluster) DelNode

func (cls *Cluster) DelNode(nodeId int, immediately bool)

func (*Cluster) DiscardNode

func (cls *Cluster) DiscardNode(nodeId int)

func (*Cluster) FindRpcHandler

func (cls *Cluster) FindRpcHandler(serviceName string) rpc.IRpcHandler

func (*Cluster) GetDiscoveryNodeList

func (cls *Cluster) GetDiscoveryNodeList() []NodeInfo

func (*Cluster) GetGlobalCfg

func (cls *Cluster) GetGlobalCfg() interface{}

func (*Cluster) GetLocalNodeInfo

func (cls *Cluster) GetLocalNodeInfo() *NodeInfo

func (*Cluster) GetMasterDiscoveryNodeInfo

func (cls *Cluster) GetMasterDiscoveryNodeInfo(nodeId int) *NodeInfo

func (*Cluster) GetNodeIdByService

func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.Client, bAll bool) (error, int)

func (*Cluster) GetNodeInfo

func (cls *Cluster) GetNodeInfo(nodeId int) (NodeInfo, bool)

func (*Cluster) GetRpcClient

func (cls *Cluster) GetRpcClient(nodeId int) *rpc.Client

func (*Cluster) GetServiceCfg

func (cls *Cluster) GetServiceCfg(serviceName string) interface{}

func (*Cluster) Init

func (cls *Cluster) Init(localNodeId int, setupServiceFun SetupServiceFun) error

func (*Cluster) InitCfg

func (cls *Cluster) InitCfg(localNodeId int) error

func (*Cluster) IsConfigService

func (cls *Cluster) IsConfigService(serviceName string) bool

func (*Cluster) IsMasterDiscoveryNode

func (cls *Cluster) IsMasterDiscoveryNode() bool

func (*Cluster) IsNodeConnected

func (cls *Cluster) IsNodeConnected(nodeId int) bool

func (*Cluster) ReadClusterConfig

func (cls *Cluster) ReadClusterConfig(filepath string) (*NodeInfoList, error)

func (*Cluster) RegDiscoveryEvent

func (cls *Cluster) RegDiscoveryEvent(serviceName string)

func (*Cluster) RegRpcEvent

func (cls *Cluster) RegRpcEvent(serviceName string)

func (*Cluster) SetupServiceDiscovery

func (cls *Cluster) SetupServiceDiscovery(localNodeId int, setupServiceFun SetupServiceFun)

func (*Cluster) Start

func (cls *Cluster) Start()

func (*Cluster) Stop

func (cls *Cluster) Stop()

func (*Cluster) TriggerDiscoveryEvent

func (cls *Cluster) TriggerDiscoveryEvent(bDiscovery bool, nodeId int, serviceName []string)

func (*Cluster) UnReDiscoveryEvent

func (cls *Cluster) UnReDiscoveryEvent(serviceName string)

func (*Cluster) UnRegRpcEvent

func (cls *Cluster) UnRegRpcEvent(serviceName string)

type ConfigDiscovery

type ConfigDiscovery struct {
	// contains filtered or unexported fields
}

func (*ConfigDiscovery) InitDiscovery

func (discovery *ConfigDiscovery) InitDiscovery(localNodeId int, funDelNode FunDelNode, funSetNodeInfo FunSetNodeInfo) error

func (*ConfigDiscovery) OnNodeStop

func (discovery *ConfigDiscovery) OnNodeStop()

type DynamicDiscoveryClient

type DynamicDiscoveryClient struct {
	service.Service
	// contains filtered or unexported fields
}

func (*DynamicDiscoveryClient) InitDiscovery

func (dc *DynamicDiscoveryClient) InitDiscovery(localNodeId int, funDelNode FunDelNode, funSetNodeInfo FunSetNodeInfo) error

func (*DynamicDiscoveryClient) OnInit

func (dc *DynamicDiscoveryClient) OnInit() error

func (*DynamicDiscoveryClient) OnNodeConnected

func (dc *DynamicDiscoveryClient) OnNodeConnected(nodeId int)

func (*DynamicDiscoveryClient) OnNodeDisconnect

func (dc *DynamicDiscoveryClient) OnNodeDisconnect(nodeId int)

func (*DynamicDiscoveryClient) OnNodeStop

func (dc *DynamicDiscoveryClient) OnNodeStop()

func (*DynamicDiscoveryClient) OnStart

func (dc *DynamicDiscoveryClient) OnStart()

func (*DynamicDiscoveryClient) RPC_SubServiceDiscover

func (dc *DynamicDiscoveryClient) RPC_SubServiceDiscover(req *rpc.SubscribeDiscoverNotify) error

订阅发现的服务通知

type DynamicDiscoveryMaster

type DynamicDiscoveryMaster struct {
	service.Service
	// contains filtered or unexported fields
}

func (*DynamicDiscoveryMaster) OnInit

func (ds *DynamicDiscoveryMaster) OnInit() error

func (*DynamicDiscoveryMaster) OnNodeConnected

func (ds *DynamicDiscoveryMaster) OnNodeConnected(nodeId int)

func (*DynamicDiscoveryMaster) OnNodeDisconnect

func (ds *DynamicDiscoveryMaster) OnNodeDisconnect(nodeId int)

func (*DynamicDiscoveryMaster) OnStart

func (ds *DynamicDiscoveryMaster) OnStart()

func (*DynamicDiscoveryMaster) RPC_RegServiceDiscover

func (ds *DynamicDiscoveryMaster) RPC_RegServiceDiscover(req *rpc.ServiceDiscoverReq, res *rpc.Empty) error

收到注册过来的结点

func (*DynamicDiscoveryMaster) RpcCastGo

func (ds *DynamicDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{})

type FunDelNode

type FunDelNode func(nodeId int, immediately bool)

type FunSetNodeInfo

type FunSetNodeInfo func(nodeInfo *NodeInfo)

type IServiceDiscovery

type IServiceDiscovery interface {
	InitDiscovery(localNodeId int, funDelNode FunDelNode, funSetNodeInfo FunSetNodeInfo) error
	OnNodeStop()
}

type NodeInfo

type NodeInfo struct {
	NodeId            int
	NodeName          string
	Private           bool
	ListenAddr        string
	MaxRpcParamLen    uint32   //最大Rpc参数长度
	ServiceList       []string //所有的有序服务列表
	PublicServiceList []string //对外公开的服务列表
	DiscoveryService  []string //筛选发现的服务,如果不配置,不进行筛选
	NeighborService   []string
	// contains filtered or unexported fields
}

type NodeInfoList

type NodeInfoList struct {
	MasterDiscoveryNode []NodeInfo //用于服务发现Node
	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 OperType

type OperType int

type SetupServiceFun

type SetupServiceFun func(s ...service.IService)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL