Documentation ¶
Index ¶
- Variables
- type BroadcastArgs
- type Context
- func (c *Context) BindGate(uid int64) error
- func (c *Context) BindNode() error
- func (c *Context) Context() context.Context
- func (c *Context) Disconnect(isForce ...bool) error
- func (c *Context) GetIP() (string, error)
- 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 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 WithRegistry(r registry.Registry) Option
- func WithTimeout(timeout time.Duration) Option
- func WithTransporter(transporter transport.Transporter) Option
- type Proxy
- 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) Broadcast(ctx context.Context, args *BroadcastArgs) (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) 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) 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) Invoke(fn func())
- 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) NewServiceClient(target string) (transport.ServiceClient, 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) 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 ¶
This section is empty.
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 ¶ added in v0.0.10
type Context struct { Proxy *Proxy Request *Request Middleware *Middleware // contains filtered or unexported fields }
func (*Context) Disconnect ¶ added in v0.0.10
Disconnect 关闭来自网关的连接
type DeliverArgs ¶
type DisconnectArgs ¶ added in v0.0.3
type DisconnectArgs = link.DisconnectArgs
type EventHandler ¶
type EventHandler func(event *Event)
type Events ¶ added in v0.0.10
type Events struct {
// contains filtered or unexported fields
}
func (*Events) AddEventHandler ¶ added in v0.0.10
func (e *Events) AddEventHandler(event cluster.Event, handler EventHandler)
AddEventHandler 添加事件处理器
type Middleware ¶ added in v0.0.10
type Middleware struct {
// contains filtered or unexported fields
}
func (*Middleware) Skip ¶ added in v0.0.10
func (m *Middleware) Skip(ctx *Context, skip int)
Skip 跳过N个中间件
type MiddlewareHandler ¶ added in v0.0.10
type MiddlewareHandler func(ctx *Context)
type MulticastArgs ¶
type MulticastArgs = link.MulticastArgs
type Option ¶
type Option func(o *options)
func WithDecryptor ¶ added in v0.0.6
WithDecryptor 设置消息解密器
func WithEncryptor ¶ added in v0.0.6
WithEncryptor 设置消息加密器
func WithLocator ¶ added in v0.0.3
WithLocator 设置定位器
func WithTransporter ¶ added in v0.0.4
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) Deliver ¶ added in v0.0.6
func (p *Proxy) Deliver(ctx context.Context, args *DeliverArgs) error
Deliver 投递消息给节点处理
func (*Proxy) Disconnect ¶ added in v0.0.3
func (p *Proxy) Disconnect(ctx context.Context, args *DisconnectArgs) error
Disconnect 断开连接
func (*Proxy) FetchGateList ¶ added in v0.0.3
func (p *Proxy) FetchGateList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchGateList 拉取网关列表
func (*Proxy) FetchNodeList ¶ added in v0.0.3
func (p *Proxy) FetchNodeList(ctx context.Context, states ...cluster.State) ([]*registry.ServiceInstance, error)
FetchNodeList 拉取节点列表
func (*Proxy) GetNodeName ¶ added in v0.0.10
GetNodeName 获取当前节点名称
func (*Proxy) GetNodeState ¶ added in v0.0.10
GetNodeState 获取当前节点状态
func (*Proxy) LocateGate ¶
LocateGate 定位用户所在网关
func (*Proxy) LocateNode ¶
LocateNode 定位用户所在节点
func (*Proxy) NewServiceClient ¶ added in v0.0.17
func (p *Proxy) NewServiceClient(target string) (transport.ServiceClient, error)
NewServiceClient 新建微服务客户端 target参数可分为两种模式: 直连模式: direct://127.0.0.1:8011 服务发现模式: discovery://service_name
func (*Proxy) SetNodeState ¶ added in v0.0.10
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 ¶ added in v0.0.10
type Router struct {
// contains filtered or unexported fields
}
func (*Router) AddRouteHandler ¶ added in v0.0.10
func (r *Router) AddRouteHandler(route int32, stateful bool, handler RouteHandler, middlewares ...MiddlewareHandler)
AddRouteHandler 添加路由处理器
func (*Router) CheckRouteStateful ¶ added in v0.0.10
CheckRouteStateful 是否为有状态路由
func (*Router) Group ¶ added in v0.0.10
func (r *Router) Group(groups ...func(group *RouterGroup)) *RouterGroup
Group 路由组
func (*Router) HasDefaultRouteHandler ¶ added in v0.0.10
HasDefaultRouteHandler 是否存在默认路由处理器
func (*Router) SetDefaultRouteHandler ¶ added in v0.0.10
func (r *Router) SetDefaultRouteHandler(handler RouteHandler)
SetDefaultRouteHandler 设置默认路由处理器,所有未注册的路由均走默认路由处理器
type RouterGroup ¶ added in v0.0.10
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) AddRouteHandler ¶ added in v0.0.10
func (g *RouterGroup) AddRouteHandler(route int32, stateful bool, handler RouteHandler, middlewares ...MiddlewareHandler) *RouterGroup
AddRouteHandler 添加路由处理器
func (*RouterGroup) Middleware ¶ added in v0.0.10
func (g *RouterGroup) Middleware(middlewares ...MiddlewareHandler) *RouterGroup
Middleware 添加中间件