Documentation ¶
Index ¶
- Constants
- Variables
- type BroadcastArgs
- type Context
- func (c *Context) BindGate(uid int64) error
- func (c *Context) BindNode(nid ...string) error
- func (c *Context) Context() context.Context
- func (c *Context) Disconnect(isForce ...bool) error
- func (c *Context) GetIP() (string, error)
- func (c *Context) Next()
- func (c *Context) Response(message interface{}) error
- func (c *Context) UnbindGate() error
- func (c *Context) UnbindNode() error
- type DeliverArgs
- type DisconnectArgs
- type Event
- type EventHandler
- type Events
- type GetIPArgs
- type Message
- type Middleware
- type MiddlewareHandler
- type MulticastArgs
- type Node
- type Option
- func WithCatServer(catServer *cat.Server) Option
- func WithCodec(codec encoding.Codec) Option
- func WithContext(ctx context.Context) Option
- func WithDecryptor(decryptor crypto.Decryptor) Option
- func WithEncryptor(encryptor crypto.Encryptor) Option
- func WithID(id string) Option
- func WithLocator(locator locate.Locator) Option
- func WithName(name string) Option
- func WithPromServer(promServer *prometheus.PromServer) Option
- func WithRegistry(r registry.Registry) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTransporter(transporter transport.Transporter) Option
- type Proxy
- func (p *Proxy) AskGate(ctx context.Context, uid int64, gid string) (string, bool, error)
- func (p *Proxy) AskNode(ctx context.Context, uid int64, nid string) (string, bool, error)
- func (p *Proxy) BindGate(ctx context.Context, uid int64, gid string, cid int64) error
- func (p *Proxy) BindNode(ctx context.Context, uid int64, nid ...string) error
- func (p *Proxy) BlockConn(ctx context.Context, onid string, nnid string, target uint64)
- func (p *Proxy) Broadcast(ctx context.Context, args *BroadcastArgs) (int64, error)
- func (p *Proxy) BroadcastDeliver(ctx context.Context, kind link.DeliverKind, message *Message) error
- func (p *Proxy) BroadcastToGame(ctx context.Context, nodeList []*registry.ServiceInstance, message *Message) (int64, error)
- func (p *Proxy) Deliver(ctx context.Context, args *DeliverArgs) error
- func (p *Proxy) Disconnect(ctx context.Context, args *DisconnectArgs) error
- func (p *Proxy) Events() *Events
- func (p *Proxy) FetchCenterList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (p *Proxy) FetchGameList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (p *Proxy) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (p *Proxy) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
- func (p *Proxy) GetID(ctx context.Context, args *link.GetIdArgs) (int64, error)
- func (p *Proxy) GetIP(ctx context.Context, args *GetIPArgs) (string, error)
- func (p *Proxy) GetNodeID() string
- func (p *Proxy) GetNodeName() string
- func (p *Proxy) GetNodeState() cluster.State
- func (p *Proxy) GetServerIP() string
- func (p *Proxy) GetServerPort() string
- func (p *Proxy) Invoke(fn func())
- func (p *Proxy) IsOnline(ctx context.Context, args *link.IsOnlineArgs) (bool, error)
- func (p *Proxy) LocateGate(ctx context.Context, uid int64) (string, error)
- func (p *Proxy) LocateNode(ctx context.Context, uid int64) (string, error)
- func (p *Proxy) Multicast(ctx context.Context, args *MulticastArgs) (int64, error)
- func (p *Proxy) MulticastDeliver(ctx context.Context, kind link.DeliverKind, targets []string, message *Message) error
- func (p *Proxy) Ping(ctx context.Context, message string) (string, error)
- func (p *Proxy) Push(ctx context.Context, args *PushArgs) error
- func (p *Proxy) Response(ctx context.Context, req *Request, message interface{}) error
- func (p *Proxy) Router() *Router
- func (p *Proxy) SetNodeState(state cluster.State)
- func (p *Proxy) Stat(ctx context.Context, kind session.Kind) (int64, error)
- func (p *Proxy) UnbindGate(ctx context.Context, uid int64) error
- func (p *Proxy) UnbindNode(ctx context.Context, uid int64, nid ...string) error
- type PushArgs
- type Request
- type RouteHandler
- type Router
- func (r *Router) AddRouteHandler(route int32, stateful bool, handler RouteHandler, ...)
- func (r *Router) CheckRouteStateful(route int32) (stateful bool, exist bool)
- func (r *Router) Group(groups ...func(group *RouterGroup)) *RouterGroup
- func (r *Router) HasDefaultRouteHandler() bool
- func (r *Router) SetDefaultRouteHandler(handler RouteHandler)
- type RouterGroup
Constants ¶
const (
Handler = "handler"
)
Variables ¶
var ( ErrInvalidGID = link.ErrInvalidGID ErrInvalidNID = link.ErrInvalidNID ErrInvalidMessage = link.ErrInvalidMessage ErrInvalidArgument = link.ErrInvalidArgument ErrInvalidSessionKind = link.ErrInvalidSessionKind ErrNotFoundUserSource = link.ErrNotFoundUserSource ErrReceiveTargetEmpty = link.ErrReceiveTargetEmpty )
Functions ¶
This section is empty.
Types ¶
type BroadcastArgs ¶
type BroadcastArgs = link.BroadcastArgs
type Context ¶
type Context struct { Proxy *Proxy Request *Request Middleware *Middleware Handler RouteHandler // contains filtered or unexported fields }
func (*Context) Disconnect ¶
Disconnect 关闭来自网关的连接
type DeliverArgs ¶
type DisconnectArgs ¶
type DisconnectArgs = link.DisconnectArgs
type EventHandler ¶
type EventHandler func(event *Event)
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
func (*Events) AddEventHandler ¶
func (e *Events) AddEventHandler(event cluster.Event, handler EventHandler)
AddEventHandler 添加事件处理器
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
type MiddlewareHandler ¶
type MiddlewareHandler func(ctx *Context)
type MulticastArgs ¶
type MulticastArgs = link.MulticastArgs
type Option ¶
type Option func(o *options)
func WithCatServer ¶ added in v0.0.23
WithCatServer 设置cat server
func WithPromServer ¶ added in v0.0.23
func WithPromServer(promServer *prometheus.PromServer) Option
WithPromServer 设置prom server
func WithTransporter ¶
func WithTransporter(transporter transport.Transporter) Option
WithTransporter 设置消息传输器
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
func (*Proxy) BindNode ¶
BindNode 绑定节点 单个用户只能被绑定到某一台节点服务器上,多次绑定会直接覆盖上次绑定 绑定操作会通过发布订阅方式同步到网关服务器和其他相关节点服务器上 NID 为需要绑定的节点ID,默认绑定到当前节点上
func (*Proxy) BroadcastDeliver ¶ added in v0.0.23
func (p *Proxy) BroadcastDeliver(ctx context.Context, kind link.DeliverKind, message *Message) error
BroadcastDeliver 推送广播消息到node节点
func (*Proxy) BroadcastToGame ¶ added in v0.0.23
func (p *Proxy) BroadcastToGame(ctx context.Context, nodeList []*registry.ServiceInstance, message *Message) (int64, error)
BroadcastToGame 推送广播消息到游戏节点
func (*Proxy) Deliver ¶
func (p *Proxy) Deliver(ctx context.Context, args *DeliverArgs) error
Deliver 投递消息给节点处理
func (*Proxy) Disconnect ¶
func (p *Proxy) Disconnect(ctx context.Context, args *DisconnectArgs) error
Disconnect 断开连接
func (*Proxy) FetchCenterList ¶ added in v0.0.23
func (p *Proxy) FetchCenterList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchCenterList 拉取Center节点列表
func (*Proxy) FetchGameList ¶ added in v0.0.23
func (p *Proxy) FetchGameList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchGameList 拉取游戏节点列表
func (*Proxy) FetchGateList ¶
func (p *Proxy) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchGateList 拉取网关列表
func (*Proxy) FetchNodeList ¶
func (p *Proxy) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchNodeList 拉取节点列表
func (*Proxy) GetServerIP ¶ added in v0.0.23
GetServerIP 获取GRPC SERVER IP
func (*Proxy) GetServerPort ¶ added in v0.0.23
GetServerPort 获取GRPC SERVER Port
func (*Proxy) LocateGate ¶
LocateGate 定位用户所在网关
func (*Proxy) LocateNode ¶
LocateNode 定位用户所在节点
func (*Proxy) MulticastDeliver ¶ added in v0.0.23
func (p *Proxy) MulticastDeliver(ctx context.Context, kind link.DeliverKind, targets []string, message *Message) error
MulticastDeliver 推送广播消息到node节点
func (*Proxy) SetNodeState ¶
SetNodeState 设置当前节点状态
func (*Proxy) UnbindGate ¶
UnbindGate 解绑网关
type Request ¶
type Request struct { GID string // 来源网关ID NID string // 来源节点ID CID int64 // 连接ID UID int64 // 用户ID Message *Message // 请求消息 // contains filtered or unexported fields }
Request 请求数据
type RouteHandler ¶
type RouteHandler func(ctx *Context)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AddRouteHandler ¶
func (r *Router) AddRouteHandler(route int32, stateful bool, handler RouteHandler, middlewares ...MiddlewareHandler)
AddRouteHandler 添加路由处理器
func (*Router) CheckRouteStateful ¶
CheckRouteStateful 是否为有状态路由
func (*Router) Group ¶
func (r *Router) Group(groups ...func(group *RouterGroup)) *RouterGroup
Group 路由组
func (*Router) HasDefaultRouteHandler ¶
HasDefaultRouteHandler 是否存在默认路由处理器
func (*Router) SetDefaultRouteHandler ¶
func (r *Router) SetDefaultRouteHandler(handler RouteHandler)
SetDefaultRouteHandler 设置默认路由处理器,所有未注册的路由均走默认路由处理器
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) AddRouteHandler ¶
func (g *RouterGroup) AddRouteHandler(route int32, stateful bool, handler RouteHandler, middlewares ...MiddlewareHandler) *RouterGroup
AddRouteHandler 添加路由处理器
func (*RouterGroup) Middleware ¶
func (g *RouterGroup) Middleware(middlewares ...MiddlewareHandler) *RouterGroup
Middleware 添加中间件