Help us shape the future of Go! Take the 2026 Go Developer Survey

cluster

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastArgs

type BroadcastArgs struct {
	Kind    session.Kind // 会话类型,session.Conn 或 session.User
	Message *Message     // 消息
}

type DeliverArgs

type DeliverArgs struct {
	NID     string   // 接收节点。存在接收节点时,消息会直接投递给接收节点;不存在接收节点时,系统定位用户所在节点,然后投递。
	UID     int64    // 用户ID
	Message *Message // 消息
}

type DisconnectArgs

type DisconnectArgs struct {
	GID    string       // 网关ID,会话类型为用户时可忽略此参数
	Kind   session.Kind // 会话类型,session.Conn 或 session.User
	Target int64        // 会话目标,CID 或 UID
	Force  bool         // 是否强制断开
}

type Dispatch added in v2.3.1

type Dispatch string

无状态路由消息分发策略

const (
	Random           Dispatch = "random" // 随机
	RoundRobin       Dispatch = "rr"     // 轮询
	WeightRoundRobin Dispatch = "wrr"    // 加权轮询
)

type Event

type Event int

Event 事件

const (
	Connect    Event = iota + 1 // 打开连接
	Reconnect                   // 断线重连
	Disconnect                  // 断开连接
)

func (Event) String

func (e Event) String() string

type GetIPArgs

type GetIPArgs struct {
	GID    string       // 网关ID,会话类型为用户时可忽略此参数
	Kind   session.Kind // 会话类型,session.Conn 或 session.User
	Target int64        // 会话目标,CID 或 UID
}

type Hook

type Hook int

Hook 生命周期钩子

const (
	Init    Hook = iota // 初始组件
	Start               // 启动组件
	Close               // 关闭组件
	Destroy             // 销毁组件
)

func (Hook) String

func (h Hook) String() string

type IsOnlineArgs

type IsOnlineArgs struct {
	GID    string       // 网关ID,会话类型为用户时可忽略此参数
	Kind   session.Kind // 会话类型,session.Conn 或 session.User
	Target int64        // 会话目标,CID 或 UID
}

type Kind

type Kind int

Kind 集群实例类型

const (
	Gate   Kind = iota + 1 // 网关服
	Node                   // 节点服
	Mesh                   // 微服务
	Master                 // 管理服
)

func (Kind) String

func (k Kind) String() string

type Message

type Message struct {
	Seq   int32 // 序列号
	Route int32 // 路由ID
	Data  any   // 消息数据,接收json、proto、[]byte
}

type MulticastArgs

type MulticastArgs struct {
	GID     string       // 网关ID,会话类型为用户时可忽略此参数
	Kind    session.Kind // 会话类型,session.Conn 或 session.User
	Targets []int64      // 会话目标,CID 或 UID
	Message *Message     // 消息
}

type PublishArgs added in v2.3.1

type PublishArgs struct {
	Channel string   // 频道
	Message *Message // 消息
}

type PushArgs

type PushArgs struct {
	GID     string       // 网关ID,会话类型为用户时可忽略此参数
	Kind    session.Kind // 会话类型,session.Conn 或 session.User
	Target  int64        // 会话目标,CID 或 UID
	Message *Message     // 消息
}

type State

type State int

State 集群实例状态

const (
	Shut State = iota // 关闭(节点已经关闭,无法正常访问该节点)
	Work              // 工作(节点正常工作,可以分配更多玩家到该节点)
	Busy              // 繁忙(节点资源紧张,不建议分配更多玩家到该节点上)
	Hang              // 挂起(节点即将销毁,正处于资源回收中)
)

func (State) String

func (s State) String() string

type SubscribeArgs added in v2.3.1

type SubscribeArgs struct {
	GID     string       // 网关ID,会话类型为用户时可忽略此参数
	Kind    session.Kind // 会话类型,session.Conn 或 session.User
	Targets []int64      // 会话目标,CID 或 UID
	Channel string       // 频道
}

type TriggerArgs

type TriggerArgs struct {
	Event int   // 事件
	CID   int64 // 连接ID
	UID   int64 // 用户ID
}

type UnsubscribeArgs added in v2.3.1

type UnsubscribeArgs struct {
	GID     string       // 网关ID,会话类型为用户时可忽略此参数
	Kind    session.Kind // 会话类型,session.Conn 或 session.User
	Targets []int64      // 会话目标,CID 或 UID
	Channel string       // 频道
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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