drpc

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnknownError        int32 = -1
	CodeOK                  int32 = 0      // nil error (ok)
	CodeNoError             int32 = CodeOK // nil error (ok)
	CodeInvalidOp           int32 = 1
	CodeWrongConn           int32 = 100
	CodeConnClosed          int32 = 102
	CodeWriteFailed         int32 = 104
	CodeDialFailed          int32 = 105
	CodeBadMessage          int32 = 400
	CodeUnauthorized        int32 = 401
	CodeNotFound            int32 = 404
	CodeMTypeNotAllowed     int32 = 405
	CodeHandleTimeout       int32 = 408
	CodeInternalServerError int32 = 500
	CodeBadGateway          int32 = 502
)

框架保留 Status code 建议自定义代码大于1000 未知错误:-1 发送错误: 100-199 消息处理错误: 400-499 接收错误: 500-599

Variables

View Source
var DefaultProtoFunc = socket.DefaultProtoFunc

DefaultProtoFunc 默认传输协议

View Source
var ErrListenClosed = errors.New("listener is closed")
View Source
var GetReadLimit = message.MsgSizeLimit

GetReadLimit 获取消息最大长度限制

View Source
var (
	NewStatus = status.New
)
View Source
var SetDefaultProtoFunc = socket.SetDefaultProtoFunc

SetDefaultProtoFunc 设置默认传输协议

View Source
var SetReadLimit = message.SetMsgSizeLimit

SetReadLimit 设置消息最大长度限制

View Source
var SetSocketKeepAlive = socket.SetKeepAlive

SetSocketKeepAlive 开启关闭链接保活

View Source
var SetSocketKeepAlivePeriod = socket.SetKeepAlivePeriod

SetSocketKeepAlivePeriod 链接保活间隔时间

View Source
var SetSocketNoDelay = socket.SetNoDelay

SetSocketNoDelay 开启关闭no delay算法

View Source
var SetSocketReadBuffer = socket.SetReadBuffer

SetSocketReadBuffer 设置链接读缓冲区长度

View Source
var SetSocketWriteBuffer = socket.SetWriteBuffer

SetSocketWriteBuffer 设置链接写缓冲区长度

View Source
var SocketReadBuffer = socket.ReadBuffer

SocketReadBuffer 获取链接读缓冲区长度

View Source
var SocketWriteBuffer = socket.WriteBuffer

SocketWriteBuffer 获取链接写缓冲区长度

Functions

func CodeText

func CodeText(statCode int32) string

func DefaultBodyCodec

func DefaultBodyCodec() codec.Codec

func GraceSignal

func GraceSignal()

func HTTPServiceMethodMapper

func HTTPServiceMethodMapper(prefix, name string) string

HTTPServiceMethodMapper like most RPC services service method mapper. Such as: user/get It is the default mapper. The mapping rule of struct(func) name to service methods:

`AaBb` -> `/aa_bb`
`ABcXYz` -> `/abc_xyz`
`Aa__Bb` -> `/aa_bb`
`aa__bb` -> `/aa_bb`
`ABC__XYZ` -> `/abc_xyz`
`Aa_Bb` -> `/aa/bb`
`aa_bb` -> `/aa/bb`
`ABC_XYZ` -> `/abc/xyz`

func NewInheritedListener

func NewInheritedListener(addr net.Addr, tlsConfig *tls.Config) (lis net.Listener, err error)

NewInheritedListener 创建一个支持优雅重启,支持继承监听的监听器

func NewTLSConfigFromFile

func NewTLSConfigFromFile(tlsCertFile, tlsKeyFile string, insecureSkipVerifyForClient ...bool) (*tls.Config, error)

NewTLSConfigFromFile 通过证书文件生成证书信息

func PopParentAddr

func PopParentAddr(network, host, addr string) string

PopParentAddr 从监听变量中出栈指定的地址端口

func PushParentAddr

func PushParentAddr(network, host, addr string)

PushParentAddr 把监听的地址端口写入到变量,优雅结束的时候写入到环境变量,让子进程使用

func Reboot

func Reboot(timeout ...time.Duration)

Reboot 重启服务

func SetDefaultBodyCodec

func SetDefaultBodyCodec(codecID byte) error

SetDefaultBodyCodec 设置默认消息体编码格式

func SetServiceMethodMapper

func SetServiceMethodMapper(mapper ServiceMethodMapper)

func SetShutdown

func SetShutdown(timeout time.Duration, firstFunc, beforeExitingFunc func() error)

SetShutdown 设置优化退出方案基本参数

func Shutdown

func Shutdown(timeout ...time.Duration)

Shutdown 关闭服务

Types

type AfterAcceptPlugin

type AfterAcceptPlugin interface {
	Plugin
	AfterAccept(EarlySession) *Status
}

AfterAcceptPlugin 作为服务端,接收到客户端的链接后触发该事件

type AfterDialPlugin

type AfterDialPlugin interface {
	Plugin
	AfterDial(sess EarlySession, isRedial bool) *Status
}

AfterDialPlugin 作为客户端链接到服务端成功以后触发该事件

type AfterDisconnectPlugin

type AfterDisconnectPlugin interface {
	Plugin
	AfterDisconnect(BaseSession) *Status
}

AfterDisconnectPlugin 断开会话以后触发该事件

type AfterListenPlugin

type AfterListenPlugin interface {
	Plugin
	AfterListen(net.Addr) error
}

AfterListenPlugin 监听以后触发该事件

type AfterNewEndpointPlugin

type AfterNewEndpointPlugin interface {
	Plugin
	AfterNewEndpoint(EarlyEndpoint) error
}

AfterNewEndpointPlugin 创建Endpoint之后触发该事件

type AfterReadCallBodyPlugin

type AfterReadCallBodyPlugin interface {
	Plugin
	AfterReadCallBody(ReadCtx) *Status
}

AfterReadCallBodyPlugin 读取CALL消息的body之后触发该事件

type AfterReadCallHeaderPlugin

type AfterReadCallHeaderPlugin interface {
	Plugin
	AfterReadCallHeader(ReadCtx) *Status
}

AfterReadCallHeaderPlugin 读取CALL消息的Header之后触发该事件

type AfterReadPushBodyPlugin

type AfterReadPushBodyPlugin interface {
	Plugin
	AfterReadPushBody(ReadCtx) *Status
}

AfterReadPushBodyPlugin 读取PUSH消息body之后触发该事件

type AfterReadPushHeaderPlugin

type AfterReadPushHeaderPlugin interface {
	Plugin
	AfterReadPushHeader(ReadCtx) *Status
}

AfterReadPushHeaderPlugin 读取PUSH消息Header之后触发该事件

type AfterReadReplyBodyPlugin

type AfterReadReplyBodyPlugin interface {
	Plugin
	AfterReadReplyBody(ReadCtx) *Status
}

AfterReadReplyBodyPlugin 读取REPLY消息body之后触发该事件

type AfterReadReplyHeaderPlugin

type AfterReadReplyHeaderPlugin interface {
	Plugin
	AfterReadReplyHeader(ReadCtx) *Status
}

AfterReadReplyHeaderPlugin 读取REPLY消息Header之前触发该事件

type AfterRegRouterPlugin

type AfterRegRouterPlugin interface {
	Plugin
	AfterRegRouter(*Handler) error
}

AfterRegRouterPlugin 路由注册成功触发该事件

type AfterWriteCallPlugin

type AfterWriteCallPlugin interface {
	Plugin
	AfterWriteCall(WriteCtx) *Status
}

AfterWriteCallPlugin 写入CALL消息成功之后触发该事件

type AfterWritePushPlugin

type AfterWritePushPlugin interface {
	Plugin
	AfterWritePush(WriteCtx) *Status
}

AfterWritePushPlugin 写入PUSH消息成功之后触发该事件

type AfterWriteReplyPlugin

type AfterWriteReplyPlugin interface {
	Plugin
	AfterWriteReply(WriteCtx) *Status
}

AfterWriteReplyPlugin 写入Reply消息成功之后触发该事件

type BaseEndpoint

type BaseEndpoint interface {

	// Close 关闭该端点
	Close() (err error)

	// CountSession 统计该端点上的session数量
	CountSession() int

	// GetSession 获取指定ID的 session
	GetSession(sessionID string) (Session, bool)

	// RangeSession 循环迭代session
	RangeSession(fn func(sess Session) bool)

	// SetTLSConfig 设置证书配置
	SetTLSConfig(tlsConfig *tls.Config)

	// SetTLSConfigFromFile 从文件中读取证书并设置证书配置
	SetTLSConfigFromFile(tlsCertFile, tlsKeyFile string, insecureSkipVerifyForClient ...bool) error

	// TLSConfig tls配置对象
	TLSConfig() *tls.Config

	// PluginContainer 插件容器对象
	PluginContainer() *PluginContainer
}

type BaseSession

type BaseSession interface {
	Endpoint() Endpoint

	// ID 获取id
	ID() string

	// LocalAddr 本地地址
	LocalAddr() net.Addr

	// RemoteAddr 远端地址
	RemoteAddr() net.Addr

	// Swap 返回交换区的内容
	Swap() *dmap.Map
}

BaseSession 基础的session

type BeforeNewEndpointPlugin

type BeforeNewEndpointPlugin interface {
	Plugin
	BeforeNewEndpoint(*EndpointConfig, *PluginContainer) error
}

BeforeNewEndpointPlugin 创建Endpoint之前触发该事件

type BeforeReadCallBodyPlugin

type BeforeReadCallBodyPlugin interface {
	Plugin
	BeforeReadCallBody(ReadCtx) *Status
}

BeforeReadCallBodyPlugin 读取CALL 消息的body之前触发该事件

type BeforeReadHeaderPlugin

type BeforeReadHeaderPlugin interface {
	Plugin
	BeforeReadHeader(EarlyCtx) error
}

BeforeReadHeaderPlugin 执行读取Header之前触发该事件

type BeforeReadPushBodyPlugin

type BeforeReadPushBodyPlugin interface {
	Plugin
	BeforeReadPushBody(ReadCtx) *Status
}

BeforeReadPushBodyPlugin 读取PUSH消息body之前触发该事件

type BeforeReadReplyBodyPlugin

type BeforeReadReplyBodyPlugin interface {
	Plugin
	BeforeReadReplyBody(ReadCtx) *Status
}

BeforeReadReplyBodyPlugin 读取REPLY消息body之前触发该事件

type BeforeWriteCallPlugin

type BeforeWriteCallPlugin interface {
	Plugin
	BeforeWriteCall(WriteCtx) *Status
}

BeforeWriteCallPlugin 写入CALL消息之前触发该事件

type BeforeWritePushPlugin

type BeforeWritePushPlugin interface {
	Plugin
	BeforeWritePush(WriteCtx) *Status
}

BeforeWritePushPlugin 写入PUSH消息之前触发该事件

type BeforeWriteReplyPlugin

type BeforeWriteReplyPlugin interface {
	Plugin
	BeforeWriteReply(WriteCtx) *Status
}

BeforeWriteReplyPlugin 写入Reply消息之前触发该事件

type CallCmd

type CallCmd interface {
	TraceEndpoint() (e Endpoint, found bool)
	TraceSession() (sess Session, found bool)

	// Context 协程上下文
	Context() context.Context
	// Output 发送的消息
	Output() message.Message

	// StatusOK 状态是否是OK
	StatusOK() bool
	// Status 状态
	Status() *Status
	// Done 返回指示是否已经完毕的chan
	Done() <-chan struct{}
	// Reply 返回应答
	Reply() (interface{}, *Status)

	// InputBodyCodec 接收到的消息使用的编码
	InputBodyCodec() byte
	// InputMeta 接收到的消息传入的元数据
	InputMeta() *dmap.Map
	// CostTime 消耗的时间
	CostTime() time.Duration
}

CallCmd CALL 命令调用后,响应操作的命令

type CallCtx

type CallCtx interface {

	// Input 获取传入的消息
	Input() message.Message

	// GetBodyCodec 获取当前消息的编码格式
	GetBodyCodec() byte

	// Output 将要发送的消息对象
	Output() message.Message

	// ReplyBodyCodec 获取响应消息的编码格式
	ReplyBodyCodec() byte

	// SetBodyCodec 设置响应消息的编码格式
	SetBodyCodec(byte)

	// SetMeta 设置指定key的值
	SetMeta(key, value string)

	// AddTFilterId 设置回复消息传输层的编码过滤方法id
	AddTFilterId(filterID ...byte)
	// contains filtered or unexported methods
}

CallCtx call消息使用的上下文

type CtxSession

type CtxSession interface {

	// ID 获取id
	ID() string

	// LocalAddr 本地地址
	LocalAddr() net.Addr

	// RemoteAddr 远端地址
	RemoteAddr() net.Addr

	// Swap 返回交换区的内容
	Swap() *dmap.Map

	// CloseNotify 返回该链接被关闭时候的通知
	CloseNotify() <-chan struct{}

	// Health 检查该session是否健康
	Health() bool

	// AsyncCall 发送消息,并异步接收响应
	AsyncCall(serviceMethod string, args interface{}, result interface{}, callCmdChan chan<- CallCmd, setting ...message.MsgSetting) CallCmd

	// Call 发送消息并获得响应值
	Call(serviceMethod string, args interface{}, result interface{}, setting ...message.MsgSetting) CallCmd

	// Push 发送消息,不接收响应,只返回发送状态
	Push(serviceMethod string, args interface{}, setting ...message.MsgSetting) *status.Status

	// SessionAge 获取session最大的生存周期
	SessionAge() time.Duration

	// ContextAge 获取 CALL 和 PUSH 消息的最大生存周期
	ContextAge() time.Duration
}

CtxSession 在处理程序上下文中传递的会话对象

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer 拨号器

func NewDialer

func NewDialer(localAddr net.Addr, tlsConfig *tls.Config, dialTimeout, redialInterval time.Duration, redialTimes int) *Dialer

NewDialer 创建一个拨号器

func (*Dialer) Dial

func (that *Dialer) Dial(addr string) (net.Conn, error)

Dial 拨号链接地址 addr

func (*Dialer) DialTimeout

func (that *Dialer) DialTimeout() time.Duration

DialTimeout 获取拨号器拨号时候的超时时间

func (*Dialer) LocalAddr

func (that *Dialer) LocalAddr() net.Addr

LocalAddr 获取拨号器本地使用的端口地址

func (*Dialer) Network

func (that *Dialer) Network() string

Network 获取拨号器的网络类型

func (*Dialer) RedialInterval

func (that *Dialer) RedialInterval() time.Duration

RedialInterval 返回拨号器重试拨号时候的间隔

func (*Dialer) RedialTimes

func (that *Dialer) RedialTimes() int

RedialTimes 拨号器重复拨号的最大次数

func (*Dialer) TLSConfig

func (that *Dialer) TLSConfig() *tls.Config

TLSConfig 获取tls配置信息

type EarlyCtx

type EarlyCtx interface {

	// Endpoint 获取当前Endpoint
	Endpoint() Endpoint

	// Session 返回当前的session
	Session() CtxSession

	// IP 返回远端ip
	IP() string

	// RealIP 返回远端真实ip
	RealIP() string

	// Swap 返回自定义交换区数据
	Swap() *dmap.Map

	// Context 获取上下文
	Context() context.Context
}

EarlyCtx 基础上下文

type EarlyEndpoint

type EarlyEndpoint interface {
	BaseEndpoint

	// Router 获取路由对象
	Router() *Router

	// SubRoute 获取分组路由对象
	SubRoute(pathPrefix string, plugin ...Plugin) *SubRouter

	// RouteCall 通过struct注册CALL类型的处理程序,并且返回注册的路径列表
	RouteCall(ctrlStruct interface{}, plugin ...Plugin) []string
	// RouteCallFunc 通过func注册CALL类型的处理程序,并且返回单个注册路径
	RouteCallFunc(callHandleFunc interface{}, plugin ...Plugin) string
	// RoutePush 通过struct注册PUSH类型的处理程序,并且返回注册的路径列表
	RoutePush(ctrlStruct interface{}, plugin ...Plugin) []string
	// RoutePushFunc 通过func注册PUSH类型的处理程序,并且返回单个注册路径
	RoutePushFunc(pushHandleFunc interface{}, plugin ...Plugin) string
	// SetUnknownCall 设置默认处理程序,当没有找到CALL的处理程序时将调用该处理程序。
	SetUnknownCall(fn func(UnknownCallCtx) (interface{}, *status.Status), plugin ...Plugin)
	// SetUnknownPush 设置默认处理程序,当没有找到PUSH的处理程序时将调用该处理程序。
	SetUnknownPush(fn func(UnknownPushCtx) *status.Status, plugin ...Plugin)
}

type EarlySession

type EarlySession interface {
	Endpoint() Endpoint

	// LocalAddr 本地地址
	LocalAddr() net.Addr

	// RemoteAddr 远端地址
	RemoteAddr() net.Addr

	// Swap 临时存储区内容
	Swap() *dmap.Map

	// SetID 设置seaside
	SetID(newID string)

	// ControlFD 原始链接的fd
	ControlFD(f func(fd uintptr)) error

	// ModifySocket 修改session的底层socket
	ModifySocket(fn func(conn net.Conn) (modifiedConn net.Conn, newProtoFunc proto.ProtoFunc))

	// GetProtoFunc 获取协议方法
	GetProtoFunc() proto.ProtoFunc

	// EarlySend 在会话刚建立的时候临时发送消息,不执行任何中间件
	EarlySend(mType byte, serviceMethod string, body interface{}, stat *status.Status, setting ...message.MsgSetting) (opStat *status.Status)

	// EarlyReceive 在会话刚建立的时候临时接受信息,不执行任何中间件
	EarlyReceive(newArgs message.NewBodyFunc, ctx ...context.Context) (input message.Message)

	// EarlyCall 在会话刚建立的时候临时调用call发送和接受消息,不执行任何中间件
	EarlyCall(serviceMethod string, args, reply interface{}, callSetting ...message.MsgSetting) (opStat *status.Status)

	// EarlyReply 在会话刚建立的时候临时回复消息,不执行任何中间件
	EarlyReply(req message.Message, body interface{}, stat *status.Status, setting ...message.MsgSetting) (opStat *status.Status)

	// RawPush 发送原始push消息,不执行任何中间件
	RawPush(serviceMethod string, args interface{}, setting ...message.MsgSetting) (opStat *status.Status)

	// SessionAge 获取session最大的生存周期
	SessionAge() time.Duration

	// ContextAge 获取 CALL 和 PUSH 消息的最大生存周期
	ContextAge() time.Duration

	// SetSessionAge 设置session的最大生存周期
	SetSessionAge(duration time.Duration)

	// SetContextAge 设置单个 CALL 和 PUSH 消息的最大生存周期
	SetContextAge(duration time.Duration)
}

EarlySession 尚未启动 goroutine 读取数据的链接会话

type Endpoint

type Endpoint interface {
	EarlyEndpoint

	// ListenAndServe 打开服务监听
	ListenAndServe(protoFunc ...socket.ProtoFunc) error

	// Dial 作为客户端链接到指定的服务
	Dial(addr string, protoFunc ...socket.ProtoFunc) (Session, *status.Status)

	// ServeConn 传入指定的conn,生成session
	// 提示:
	// 1. 不支持断开链接后自动重拨
	// 2. 不检查TLS
	// 3. 执行 PostAcceptPlugin 插件
	ServeConn(conn net.Conn, protoFunc ...socket.ProtoFunc) (Session, *status.Status)
}

func NewEndpoint

func NewEndpoint(cfg EndpointConfig, globalLeftPlugin ...Plugin) Endpoint

type EndpointConfig

type EndpointConfig struct {

	// 网络类型; tcp, tcp4, tcp6, unix, unixpacket, kcp or quic"
	Network string

	//当前要监听的服务器本地IP
	LocalIP string

	//需要监听的端口号
	ListenPort uint16

	// 默认的消息体编码格式
	DefaultBodyCodec string
	//默认会话生命周期
	DefaultSessionAge time.Duration
	//默认单次请求生命周期
	DefaultContextAge time.Duration
	//外部配置慢处理定义时间
	SlowCometDuration time.Duration

	//是否打印会话中请求的 body或 metadata
	PrintDetail bool
	// 是否统计消耗时间
	CountTime bool

	// 作为客户端角色时,请求服务端的超时时间
	DialTimeout time.Duration

	// 在链接中断时候,试图链接服务端的最大重试次数。仅限客户端角色使用
	RedialTimes int
	//仅限客户端角色使用 试图链接服务端时候,重试的时间间隔
	RedialInterval time.Duration
	// contains filtered or unexported fields
}

EndpointConfig 端点的配置

func (*EndpointConfig) ListenAddr

func (that *EndpointConfig) ListenAddr() net.Addr

ListenAddr 获取本地监听地址,服务器角色

func (*EndpointConfig) LocalAddr

func (that *EndpointConfig) LocalAddr() net.Addr

LocalAddr 获取本地地址,客户端角色

type FakeAddr

type FakeAddr struct {
	// contains filtered or unexported fields
}

FakeAddr 是一个虚地址对象,实现了net.Add

func NewFakeAddr

func NewFakeAddr(network, host, port string) *FakeAddr

NewFakeAddr 创建一个虚地址对象

func NewFakeAddr2

func NewFakeAddr2(network, addr string) (*FakeAddr, error)

NewFakeAddr2 创建另一个不同参数的虚地址对象

func (*FakeAddr) Host

func (f *FakeAddr) Host() string

func (*FakeAddr) Network

func (f *FakeAddr) Network() string

func (*FakeAddr) Port

func (f *FakeAddr) Port() string

func (*FakeAddr) String

func (f *FakeAddr) String() string

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) ArgElemType

func (that *Handler) ArgElemType() reflect.Type

ArgElemType 参数的类型

func (*Handler) IsCall

func (that *Handler) IsCall() bool

IsCall 处理程序是否是Call

func (*Handler) IsPush

func (that *Handler) IsPush() bool

IsPush 处理程序是否是PUSH

func (*Handler) IsUnknown

func (that *Handler) IsUnknown() bool

IsUnknown 处理程序是否未找到

func (*Handler) Name

func (that *Handler) Name() string

Name 名字

func (*Handler) NewArgValue

func (that *Handler) NewArgValue() reflect.Value

NewArgValue 参数的反射值

func (*Handler) ReplyType

func (that *Handler) ReplyType() reflect.Type

ReplyType 回复消息的类型

func (*Handler) RouterTypeName

func (that *Handler) RouterTypeName() string

RouterTypeName 获取处理器的路由方法名 pnPush/pnCall/pnUnknownPush/pnUnknownCall

type Plugin

type Plugin interface {
	Name() string
}

Plugin 插件的基础对象

type PluginContainer

type PluginContainer struct {
	// contains filtered or unexported fields
}

PluginContainer 插件容器

func (*PluginContainer) AppendLeft

func (that *PluginContainer) AppendLeft(plugins ...Plugin)

AppendLeft 追加插件到左边

func (*PluginContainer) AppendRight

func (that *PluginContainer) AppendRight(plugins ...Plugin)

AppendRight 追加插件到右边

func (PluginContainer) GetAll

func (that PluginContainer) GetAll() []Plugin

GetAll 获取所有插件列表

func (PluginContainer) GetByName

func (that PluginContainer) GetByName(pluginName string) Plugin

GetByName 通过插件名字获取插件

func (*PluginContainer) Remove

func (that *PluginContainer) Remove(pluginName string) error

Remove 根据插件名移除插件

type PushCtx

type PushCtx interface {

	// GetBodyCodec 获取当前消息的编码格式
	GetBodyCodec() byte
	// contains filtered or unexported methods
}

PushCtx push消息使用的上下文

type ReadCtx

type ReadCtx interface {

	// Input 获取传入的消息
	Input() message.Message

	// StatusOK 状态是否ok
	StatusOK() bool

	// Status 当前步骤的状态
	Status() *status.Status
	// contains filtered or unexported methods
}

ReadCtx 读取消息使用的上下文

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router 路由器

func (*Router) RouteCall

func (that *Router) RouteCall(callCtrlStruct interface{}, plugin ...Plugin) []string

RouteCall 注册struct对象到路由器

func (*Router) RouteCallFunc

func (that *Router) RouteCallFunc(callHandleFunc interface{}, plugin ...Plugin) string

RouteCallFunc 注册func对象到路由器

func (*Router) RoutePush

func (that *Router) RoutePush(pushCtrlStruct interface{}, plugin ...Plugin) []string

RoutePush 注册 PUSH 类型的处理程序到路由器

func (*Router) RoutePushFunc

func (that *Router) RoutePushFunc(pushHandleFunc interface{}, plugin ...Plugin) string

RoutePushFunc 通过func注册PUSH类型的处理程序到路由器

func (*Router) SetUnknownCall

func (that *Router) SetUnknownCall(fn func(UnknownCallCtx) (interface{}, *status.Status), plugin ...Plugin)

SetUnknownCall 注册默认的未知CALL处理方法

func (*Router) SetUnknownPush

func (that *Router) SetUnknownPush(fn func(UnknownPushCtx) *status.Status, plugin ...Plugin)

SetUnknownPush 注册未知PUSH处理方法

func (*Router) SubRoute

func (that *Router) SubRoute(prefix string, plugin ...Plugin) *SubRouter

SubRoute 添加处理程序组

type ServiceMethodMapper

type ServiceMethodMapper func(prefix, name string) (serviceMethod string)

type Session

type Session interface {
	Endpoint() Endpoint

	// SetID 设置session id
	SetID(newID string)

	// Close 关闭session
	Close() error

	CtxSession
}

type SessionHub

type SessionHub struct {
	// contains filtered or unexported fields
}

type Status

type Status = status.Status

type SubRouter

type SubRouter struct {
	// contains filtered or unexported fields
}

func (*SubRouter) Root

func (that *SubRouter) Root() *Router

Root 返回根路由器

func (*SubRouter) RouteCall

func (that *SubRouter) RouteCall(callCtrlStruct interface{}, plugin ...Plugin) []string

RouteCall 通过struct注册多个 CALL 类型的处理程序,并返回它们的注册路径

func (*SubRouter) RouteCallFunc

func (that *SubRouter) RouteCallFunc(callHandleFunc interface{}, plugin ...Plugin) string

RouteCallFunc 通过func注册单个 CALL 类型的处理程序,并返回它的注册路径

func (*SubRouter) RoutePush

func (that *SubRouter) RoutePush(pushCtrlStruct interface{}, plugin ...Plugin) []string

RoutePush 通过struct批量注册 PUSH 类型的处理程序,并返回它们的路径

func (*SubRouter) RoutePushFunc

func (that *SubRouter) RoutePushFunc(pushHandleFunc interface{}, plugin ...Plugin) string

RoutePushFunc 通过func注册PUSH类型的处理程序,并返回它的路径

func (*SubRouter) SubRoute

func (that *SubRouter) SubRoute(prefix string, plugin ...Plugin) *SubRouter

SubRoute 添加处理程序组

func (*SubRouter) ToRouter

func (that *SubRouter) ToRouter() *Router

ToRouter 转换成添加了 SetUnknownCall 和 SetUnknownPush 方法的路由器

type UnknownCallCtx

type UnknownCallCtx interface {

	// GetBodyCodec 获取当前消息的编码格式
	GetBodyCodec() byte

	// InputBodyBytes 传入消息体
	InputBodyBytes() []byte

	// BuildBody 如果push消息是未知的消息,则使用v对象解析消息内容
	BuildBody(v interface{}) (bodyCodec byte, err error)

	// SetBodyCodec 设置回复消息的编码格式
	SetBodyCodec(byte)

	// SetMeta 设置指定key的值
	SetMeta(key, value string)

	// AddTFilterId 设置回复消息传输层的编码过滤方法id
	AddTFilterId(filterID ...byte)
	// contains filtered or unexported methods
}

UnknownCallCtx 未知call消息的上下文

type UnknownPushCtx

type UnknownPushCtx interface {

	// GetBodyCodec 获取当前消息的编码格式
	GetBodyCodec() byte

	// InputBodyBytes 传入消息体
	InputBodyBytes() []byte

	// BuildBody 如果push消息是未知的消息,则使用v对象解析消息内容
	BuildBody(v interface{}) (bodyCodec byte, err error)
	// contains filtered or unexported methods
}

UnknownPushCtx 未知push消息的上下文

type WriteCtx

type WriteCtx interface {
	EarlyCtx

	// Output 将要发送的消息对象
	Output() message.Message

	// StatusOK 状态是否ok
	StatusOK() bool

	// Status 当前步骤的状态
	Status() *status.Status
}

WriteCtx 写消息时使用的上下文方法

Directories

Path Synopsis
Package message 消息对象
Package message 消息对象
plugin
ignorecase
Package ignorecase dynamically ignoring the case of path
Package ignorecase dynamically ignoring the case of path
md5

Jump to

Keyboard shortcuts

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