Documentation
¶
Index ¶
- type BroadcastArgs
- type DeliverArgs
- type DisconnectArgs
- type GateLinker
- func (l *GateLinker) AskGate(ctx context.Context, gid string, uid int64) (string, bool, error)
- func (l *GateLinker) BindGate(ctx context.Context, gid string, cid, uid int64) error
- func (l *GateLinker) Broadcast(ctx context.Context, args *BroadcastArgs) (int64, error)
- func (l *GateLinker) Disconnect(ctx context.Context, args *DisconnectArgs) error
- func (l *GateLinker) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (l *GateLinker) GetIP(ctx context.Context, args *GetIPArgs) (string, error)
- func (l *GateLinker) GetState(ctx context.Context, gid string) (cluster.State, error)
- func (l *GateLinker) HasGate(gid string) bool
- func (l *GateLinker) IsOnline(ctx context.Context, args *IsOnlineArgs) (bool, error)
- func (l *GateLinker) LocateGate(ctx context.Context, uid int64) (string, error)
- func (l *GateLinker) Multicast(ctx context.Context, args *MulticastArgs) (int64, error)
- func (l *GateLinker) PackBuffer(message any, encrypt bool) ([]byte, error)
- func (l *GateLinker) PackMessage(message *Message, encrypt bool) (buffer.Buffer, error)
- func (l *GateLinker) Publish(ctx context.Context, args *PublishArgs) (int64, error)
- func (l *GateLinker) Push(ctx context.Context, args *PushArgs) error
- func (l *GateLinker) SetState(ctx context.Context, gid string, state cluster.State) error
- func (l *GateLinker) Stat(ctx context.Context, kind session.Kind) (total int64, err error)
- func (l *GateLinker) Subscribe(ctx context.Context, args *SubscribeArgs) error
- func (l *GateLinker) UnbindGate(ctx context.Context, uid int64) error
- func (l *GateLinker) Unsubscribe(ctx context.Context, args *UnsubscribeArgs) error
- func (l *GateLinker) WatchClusterInstance()
- func (l *GateLinker) WatchUserLocate()
- type GetIPArgs
- type IsOnlineArgs
- type Message
- type MulticastArgs
- type NodeLinker
- func (l *NodeLinker) AskNode(ctx context.Context, uid int64, name, nid string) (string, bool, error)
- func (l *NodeLinker) BindNode(ctx context.Context, uid int64, name, nid string) error
- func (l *NodeLinker) Deliver(ctx context.Context, args *DeliverArgs) error
- func (l *NodeLinker) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (l *NodeLinker) GetState(ctx context.Context, nid string) (cluster.State, error)
- func (l *NodeLinker) HasNode(nid string) bool
- func (l *NodeLinker) LocateNode(ctx context.Context, uid int64, name string) (string, error)
- func (l *NodeLinker) LocateNodes(ctx context.Context, uid int64) (map[string]string, error)
- func (l *NodeLinker) PackMessage(message *Message, encrypt bool) (buffer.Buffer, error)
- func (l *NodeLinker) SetState(ctx context.Context, nid string, state cluster.State) error
- func (l *NodeLinker) Trigger(ctx context.Context, args *TriggerArgs) error
- func (l *NodeLinker) UnbindNode(ctx context.Context, uid int64, name, nid string) error
- func (l *NodeLinker) WatchClusterInstance()
- func (l *NodeLinker) WatchUserLocate()
- type Options
- type PublishArgs
- type PushArgs
- type SubscribeArgs
- type TriggerArgs
- type UnsubscribeArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastArgs ¶
type BroadcastArgs = cluster.BroadcastArgs
type DeliverArgs ¶
type DisconnectArgs ¶
type DisconnectArgs = cluster.DisconnectArgs
type GateLinker ¶ added in v2.1.0
type GateLinker struct {
// contains filtered or unexported fields
}
func NewGateLinker ¶ added in v2.1.0
func NewGateLinker(ctx context.Context, opts *Options) *GateLinker
func (*GateLinker) AskGate ¶ added in v2.5.0
AskGate reports whether the user is located on the gate identified by gid.
func (*GateLinker) BindGate ¶ added in v2.5.0
BindGate binds the connection cid and user uid to the gate identified by gid.
func (*GateLinker) Broadcast ¶ added in v2.1.0
func (l *GateLinker) Broadcast(ctx context.Context, args *BroadcastArgs) (int64, error)
Broadcast pushes a broadcast message to every gate.
func (*GateLinker) Disconnect ¶ added in v2.1.0
func (l *GateLinker) Disconnect(ctx context.Context, args *DisconnectArgs) error
Disconnect disconnects the session target.
func (*GateLinker) FetchGateList ¶ added in v2.1.0
func (l *GateLinker) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchGateList returns the gate services, optionally filtered by states.
func (*GateLinker) GetIP ¶ added in v2.1.0
GetIP returns the client IP for the given session target.
func (*GateLinker) GetState ¶ added in v2.1.0
GetState returns the state of the gate identified by gid.
func (*GateLinker) HasGate ¶ added in v2.5.0
func (l *GateLinker) HasGate(gid string) bool
HasGate reports whether the gate identified by gid exists.
func (*GateLinker) IsOnline ¶ added in v2.1.0
func (l *GateLinker) IsOnline(ctx context.Context, args *IsOnlineArgs) (bool, error)
IsOnline reports whether the session target is online.
func (*GateLinker) LocateGate ¶ added in v2.5.0
LocateGate returns the gate where the user is located.
func (*GateLinker) Multicast ¶ added in v2.1.0
func (l *GateLinker) Multicast(ctx context.Context, args *MulticastArgs) (int64, error)
Multicast pushes a message to multiple targets.
Set args.Ack to true to obtain the number of targets the message was pushed to successfully.
func (*GateLinker) PackBuffer ¶ added in v2.2.0
func (l *GateLinker) PackBuffer(message any, encrypt bool) ([]byte, error)
PackBuffer encodes message, encrypting the encoded bytes when encrypt is true.
func (*GateLinker) PackMessage ¶ added in v2.2.0
PackMessage packs a message into a buffer, optionally encrypting its payload.
func (*GateLinker) Publish ¶ added in v2.3.0
func (l *GateLinker) Publish(ctx context.Context, args *PublishArgs) (int64, error)
Publish publishes a channel message to every gate.
func (*GateLinker) Push ¶ added in v2.1.0
func (l *GateLinker) Push(ctx context.Context, args *PushArgs) error
Push pushes a message to a single target.
func (*GateLinker) SetState ¶ added in v2.1.0
SetState sets the state of the gate identified by gid.
func (*GateLinker) Stat ¶ added in v2.1.0
Stat returns the total number of sessions of the given kind across all gates.
func (*GateLinker) Subscribe ¶ added in v2.3.0
func (l *GateLinker) Subscribe(ctx context.Context, args *SubscribeArgs) error
Subscribe subscribes the targets to a channel.
func (*GateLinker) UnbindGate ¶ added in v2.5.0
func (l *GateLinker) UnbindGate(ctx context.Context, uid int64) error
UnbindGate unbinds the user from its gate.
func (*GateLinker) Unsubscribe ¶ added in v2.3.0
func (l *GateLinker) Unsubscribe(ctx context.Context, args *UnsubscribeArgs) error
Unsubscribe unsubscribes the targets from a channel.
func (*GateLinker) WatchClusterInstance ¶ added in v2.1.0
func (l *GateLinker) WatchClusterInstance()
WatchClusterInstance watches cluster instance changes and refreshes the dispatcher.
func (*GateLinker) WatchUserLocate ¶ added in v2.1.0
func (l *GateLinker) WatchUserLocate()
WatchUserLocate watches user locate events and keeps the local source cache in sync.
type IsOnlineArgs ¶ added in v2.1.0
type IsOnlineArgs = cluster.IsOnlineArgs
type MulticastArgs ¶
type MulticastArgs = cluster.MulticastArgs
type NodeLinker ¶ added in v2.1.0
type NodeLinker struct {
// contains filtered or unexported fields
}
func NewNodeLinker ¶ added in v2.1.0
func NewNodeLinker(ctx context.Context, opts *Options) *NodeLinker
func (*NodeLinker) AskNode ¶ added in v2.5.0
func (l *NodeLinker) AskNode(ctx context.Context, uid int64, name, nid string) (string, bool, error)
AskNode reports whether the user is located on the node with the given name and instance ID nid.
func (*NodeLinker) BindNode ¶ added in v2.5.0
BindNode binds the user to the node with the given name and instance ID nid.
A user may be bound to multiple node servers, but only one server per name. Binding to a server with the same name again overwrites the previous binding. The binding is propagated to the gate servers and other related node servers through publish-subscribe.
func (*NodeLinker) Deliver ¶ added in v2.1.0
func (l *NodeLinker) Deliver(ctx context.Context, args *DeliverArgs) error
Deliver delivers a message to a node for handling.
func (*NodeLinker) FetchNodeList ¶ added in v2.1.0
func (l *NodeLinker) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchNodeList returns the node services, optionally filtered by states.
func (*NodeLinker) GetState ¶ added in v2.1.0
GetState returns the state of the node identified by nid.
func (*NodeLinker) HasNode ¶ added in v2.5.0
func (l *NodeLinker) HasNode(nid string) bool
HasNode reports whether the node identified by nid exists.
func (*NodeLinker) LocateNode ¶ added in v2.5.0
LocateNode returns the node where the user is located.
func (*NodeLinker) LocateNodes ¶ added in v2.5.0
LocateNodes returns the list of nodes where the user is located.
func (*NodeLinker) PackMessage ¶ added in v2.4.0
PackMessage packs a message into a buffer, optionally encrypting its payload.
func (*NodeLinker) SetState ¶ added in v2.1.0
SetState sets the state of the node identified by nid.
func (*NodeLinker) Trigger ¶ added in v2.1.0
func (l *NodeLinker) Trigger(ctx context.Context, args *TriggerArgs) error
Trigger triggers an event on every node subscribed to it.
Events are triggered on nodes in parallel, so that dialing or a blocked write queue on one node does not slow down delivery to the others. The call waits in the background for all nodes to finish and releases the context derived by the errgroup to avoid a context leak. Failures on individual nodes are logged at the error level rather than requiring the remaining nodes to complete first.
func (*NodeLinker) UnbindNode ¶ added in v2.5.0
UnbindNode unbinds the user from the node with the given name.
The node instance ID is verified while unbinding, and the unbind fails when nid does not match. The unbind is propagated to the gate servers and other related node servers through publish-subscribe.
func (*NodeLinker) WatchClusterInstance ¶ added in v2.1.0
func (l *NodeLinker) WatchClusterInstance()
WatchClusterInstance watches cluster instance changes and refreshes the dispatcher.
func (*NodeLinker) WatchUserLocate ¶ added in v2.1.0
func (l *NodeLinker) WatchUserLocate()
WatchUserLocate watches user locate events and keeps the local source cache in sync.
type Options ¶
type Options struct {
ID string // Instance ID
Kind cluster.Kind // Instance kind
Codec encoding.Codec // Codec
Locator locate.Locator // Locator
Registry registry.Registry // Registry
Encryptor crypto.Encryptor // Encryptor
Dispatch cluster.Dispatch // Dispatch strategy for stateless routed messages
ConnNum int // Number of connections
CallTimeout time.Duration // Call timeout
DialTimeout time.Duration // Dial timeout
DialRetryTimes int // Number of dial retries
FaultRecoveryTime time.Duration // Fault recovery time
CommandQueueSize int32 // Command queue size
CommandWriteTimeout time.Duration // Command write timeout
WaitHandler func() bool // Wait handler
DoneHandler func() bool // Done handler
}
type PublishArgs ¶ added in v2.3.0
type PublishArgs = cluster.PublishArgs
type SubscribeArgs ¶ added in v2.3.0
type SubscribeArgs = cluster.SubscribeArgs
type TriggerArgs ¶
type UnsubscribeArgs ¶ added in v2.3.0
type UnsubscribeArgs = cluster.UnsubscribeArgs