cluster

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_CLUSTER_NUM = int(rpc.SERVICE_DB) + 1
	CALL_TIME_OUT   = 500 * time.Millisecond
)
View Source
const (
	ETCD_DIR        = "server/"
	MAILBOX_TL_TIME = etv3.MAILBOX_TL_TIME
)
View Source
const STUB_TTL_TIME = 30 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type CallFunc

type CallFunc struct {
	Func       interface{}
	FuncType   reflect.Type
	FuncVal    reflect.Value
	FuncParams string
}

type Cluster

type Cluster struct {
	actor.Actor
	*Service //集群注册

	MailBox     etv3.MailBox
	StubMailBox etv3.StubMailBox
	Stub        conf.Stub
	// contains filtered or unexported fields
}

集群服务器

var (
	MGR Cluster
)

func (*Cluster) AddCluster

func (c *Cluster) AddCluster(info *rpc.ClusterInfo)

func (*Cluster) BindPacketFunc

func (c *Cluster) BindPacketFunc(callfunc network.PacketFunc)

func (*Cluster) Call

func (c *Cluster) Call(parmas ...interface{})

params[0]:rpc.RpcHead params[1]:error

func (*Cluster) CallMsg

func (c *Cluster) CallMsg(cb interface{}, head rpc.RpcHead, funcName string, params ...interface{}) error

func (*Cluster) Cluster_Add

func (c *Cluster) Cluster_Add(ctx context.Context, info *rpc.ClusterInfo)

集群新加member

func (*Cluster) Cluster_Del

func (c *Cluster) Cluster_Del(ctx context.Context, info *rpc.ClusterInfo)

集群删除member

func (*Cluster) DelCluster

func (c *Cluster) DelCluster(info *rpc.ClusterInfo)

func (*Cluster) GetBalanceCluster added in v1.9.14

func (c *Cluster) GetBalanceCluster(head rpc.RpcHead) (clusterInfo *rpc.ClusterInfo)

func (*Cluster) GetCluster

func (c *Cluster) GetCluster(head rpc.RpcHead) *rpc.ClusterInfo

func (*Cluster) HandlePacket

func (c *Cluster) HandlePacket(packet rpc.Packet)

func (*Cluster) InitCluster

func (c *Cluster) InitCluster(info *rpc.ClusterInfo, Endpoints []string, natsUrl string, params ...OpOption)

func (*Cluster) IsEnoughStub

func (c *Cluster) IsEnoughStub(stub rpc.STUB) bool

func (*Cluster) RandomCluster

func (c *Cluster) RandomCluster(head rpc.RpcHead) rpc.RpcHead

func (*Cluster) Send

func (c *Cluster) Send(head rpc.RpcHead, packet rpc.Packet)

func (*Cluster) SendMsg

func (c *Cluster) SendMsg(head rpc.RpcHead, funcName string, params ...interface{})

type EmptyClusterInfo

type EmptyClusterInfo struct {
	rpc.ClusterInfo
}

func (*EmptyClusterInfo) String

func (c *EmptyClusterInfo) String() string

type HashClusterMap

type HashClusterMap map[uint32]*rpc.ClusterInfo

type HashClusterSocketMap

type HashClusterSocketMap map[uint32]*rpc.ClusterInfo

type ICluster

type ICluster interface {
	actor.IActor
	InitCluster(info *rpc.ClusterInfo, Endpoints []string, natsUrl string, params ...OpOption)
	RegisterClusterCall() //注册集群通用回调
	AddCluster(info *rpc.ClusterInfo)
	DelCluster(info *rpc.ClusterInfo)
	GetCluster(rpc.RpcHead) *rpc.ClusterInfo

	BindPacketFunc(packetFunc network.PacketFunc)
	CallMsg(interface{}, rpc.RpcHead, string, ...interface{}) error //同步给集群特定服务器

	RandomCluster(head rpc.RpcHead) rpc.RpcHead //随机分配
	IsEnoughStub(stub rpc.STUB) bool

	GetBalanceCluster(head rpc.RpcHead) (clusterInfo *rpc.ClusterInfo)
}

type Master

type Master etv3.Master

func NewMaster

func NewMaster(info rpc.IClusterInfo, Endpoints []string) *Master

监控服务器

type Op

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

type OpOption

type OpOption func(*Op)

func WithMailBoxEtcd

func WithMailBoxEtcd(Endpoints []string) OpOption

func WithStubMailBoxEtcd

func WithStubMailBoxEtcd(Endpoints []string, stub *conf.Stub) OpOption

type Service

type Service etv3.Service

func NewService

func NewService(info *rpc.ClusterInfo, Endpoints []string) *Service

注册服务器

type Snowflake

type Snowflake etv3.Snowflake

func NewSnowflake

func NewSnowflake(Endpoints []string) *Snowflake

uuid生成器

type Stub

type Stub struct {
	StubMailBox rpc.StubMailBox
	// contains filtered or unexported fields
}

stub容器

func (*Stub) InitStub

func (s *Stub) InitStub(stub rpc.STUB)

func (*Stub) IsRegister

func (s *Stub) IsRegister() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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