Documentation
¶
Overview ¶
Package cluster defines the kinds, states, events, hooks and message arguments shared by the gate, node and mesh components.
Index ¶
Constants ¶
const ( Random = def.Random // Random dispatches messages randomly RoundRobin = def.RoundRobin // RoundRobin dispatches messages in turn WeightedRoundRobin = def.WeightedRoundRobin // WeightedRoundRobin dispatches messages in turn by weight )
The dispatch strategies of stateless route messages.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastArgs ¶ added in v2.1.0
type BroadcastArgs struct {
Kind Session // Kind is the session kind, either Conn or User
Message *Message // Message is the message to broadcast
Disconnect bool // Disconnect reports whether to gracefully close the connection after pushing
Ack bool // Ack reports whether the push result should be acknowledged
}
BroadcastArgs is the arguments of broadcasting a message.
type DeliverArgs ¶ added in v2.1.0
type DeliverArgs struct {
NID string // NID is the receiving node. When it is set, the message is delivered to that node directly; otherwise the system locates the node the user belongs to and delivers the message there
UID int64 // UID is the user ID
Message *Message // Message is the message to deliver
}
DeliverArgs is the arguments of delivering a message.
type DisconnectArgs ¶ added in v2.1.0
type DisconnectArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Target int64 // Target is the session target, either a CID or a UID
Force bool // Force reports whether to force the disconnection
}
DisconnectArgs is the arguments of disconnecting a session.
type Event ¶
type Event int
Event is the event of a cluster instance.
type GetIPArgs ¶ added in v2.1.0
type GetIPArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Target int64 // Target is the session target, either a CID or a UID
}
GetIPArgs is the arguments of getting the client IP.
type Hook ¶ added in v2.1.0
type Hook int
Hook is a lifecycle hook of a component.
type IsOnlineArgs ¶ added in v2.1.0
type IsOnlineArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Target int64 // Target is the session target, either a CID or a UID
}
IsOnlineArgs is the arguments of checking whether a session is online.
type Kind ¶
type Kind int
Kind is the type of a cluster instance.
type Message ¶ added in v2.1.0
type Message struct {
Seq int32 // Seq is the sequence number
Route int32 // Route is the route ID
Data any // Data is the message payload, which accepts json, proto or []byte
}
Message is a cluster message.
type MulticastArgs ¶ added in v2.1.0
type MulticastArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Targets []int64 // Targets are the session targets, either CIDs or UIDs
Message *Message // Message is the message to multicast
Disconnect bool // Disconnect reports whether to gracefully close the connection after pushing
Ack bool // Ack reports whether the push result should be acknowledged
}
MulticastArgs is the arguments of multicasting a message.
type PublishArgs ¶ added in v2.3.0
type PublishArgs struct {
Channel string // Channel is the channel name
Message *Message // Message is the message to publish
Disconnect bool // Disconnect reports whether to gracefully close the connection after pushing
Ack bool // Ack reports whether the push result should be acknowledged
}
PublishArgs is the arguments of publishing a message to a channel.
type PushArgs ¶ added in v2.1.0
type PushArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Target int64 // Target is the session target, either a CID or a UID
Message *Message // Message is the message to push
Disconnect bool // Disconnect reports whether to gracefully close the connection after pushing
Ack bool // Ack reports whether the push result should be acknowledged
}
PushArgs is the arguments of pushing a message.
type Session ¶ added in v2.6.5
type Session int
Session is the kind of a session.
The kinds of a session.
type State ¶
type State int
State is the state of a cluster instance.
const ( Shut State = iota // Shut means the node is shut down and cannot be accessed Work // Work means the node is healthy and more players may be assigned to it Busy // Busy means the node is low on resources and should not receive more players Hang // Hang means the node is about to be destroyed and is reclaiming resources )
The states of a cluster instance.
type SubscribeArgs ¶ added in v2.3.0
type SubscribeArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Targets []int64 // Targets are the session targets, either CIDs or UIDs
Channel string // Channel is the channel name
}
SubscribeArgs is the arguments of subscribing to a channel.
type TriggerArgs ¶ added in v2.1.0
type TriggerArgs struct {
Event int // Event is the event type
CID int64 // CID is the connection ID
UID int64 // UID is the user ID
}
TriggerArgs is the arguments of triggering an event.
type UnsubscribeArgs ¶ added in v2.3.0
type UnsubscribeArgs struct {
GID string // GID is the gate ID, it may be omitted when the session kind is user
Kind Session // Kind is the session kind, either Conn or User
Targets []int64 // Targets are the session targets, either CIDs or UIDs
Channel string // Channel is the channel name
}
UnsubscribeArgs is the arguments of unsubscribing from a channel.