cluster

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 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        common.Stub
	// contains filtered or unexported fields
}

集群服务器

var (
	MGR Cluster
)

func (*Cluster) AddCluster

func (c *Cluster) AddCluster(info *common.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 *common.ClusterInfo)

集群新加member

func (*Cluster) Cluster_Del

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

集群删除member

func (*Cluster) DelCluster

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

func (*Cluster) GetBalanceServer

func (this *Cluster) GetBalanceServer(head rpc.RpcHead) *common.ClusterInfo

func (*Cluster) GetCluster

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

func (*Cluster) HandlePacket

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

func (*Cluster) InitCluster

func (c *Cluster) InitCluster(info *common.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 {
	common.ClusterInfo
}

func (*EmptyClusterInfo) String

func (c *EmptyClusterInfo) String() string

type HashClusterMap

type HashClusterMap map[uint32]*common.ClusterInfo

type HashClusterSocketMap

type HashClusterSocketMap map[uint32]*common.ClusterInfo

type ICluster

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

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

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

type Master

type Master etv3.Master

func NewMaster

func NewMaster(info common.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 *common.Stub) OpOption

type Service

type Service etv3.Service

func NewService

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

注册服务器

type Snowflake

type Snowflake etv3.Snowflake

func NewSnowflake

func NewSnowflake(Endpoints []string) *Snowflake

uuid生成器

type Stub

type Stub struct {
	StubMailBox common.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