cluster

package
v1.21.11 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func GetNodeByServiceName added in v1.18.3

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

func GetRpcClient

func GetRpcClient(nodeId int, serviceMethod string, filterRetire bool, 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 added in v1.19.3

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 added in v1.17.3

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, filterRetire bool) (error, int)

func (*Cluster) GetNodeInfo added in v1.18.3

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

func (*Cluster) GetRpcClient

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

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) IsNodeRetire added in v1.21.4

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

func (*Cluster) ReadClusterConfig

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

func (*Cluster) RegDiscoveryEvent added in v1.18.3

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 added in v1.18.3

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

func (*Cluster) UnReDiscoveryEvent added in v1.18.3

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) OnRetire added in v1.21.4

func (dc *DynamicDiscoveryClient) OnRetire()

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_NodeRetire added in v1.21.4

func (ds *DynamicDiscoveryMaster) RPC_NodeRetire(req *rpc.NodeRetireReq, res *rpc.Empty) error

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 MasterDiscoveryService added in v1.21.3

type MasterDiscoveryService struct {
	MasterNodeId     int32    //要筛选的主结点Id,如果不配置或者配置成0,表示针对所有的主结点
	DiscoveryService []string //只发现的服务列表
}

type NodeInfo

type NodeInfo struct {
	NodeId                 int
	NodeName               string
	Private                bool
	ListenAddr             string
	MaxRpcParamLen         uint32                   //最大Rpc参数长度
	CompressBytesLen       int                      //超过字节进行压缩的长度
	ServiceList            []string                 //所有的有序服务列表
	PublicServiceList      []string                 //对外公开的服务列表
	MasterDiscoveryService []MasterDiscoveryService //筛选发现的服务,如果不配置,不进行筛选

	Retire bool
	// 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