Documentation
¶
Overview ¶
Package gap Golaxy应用层协议(Golaxy Application Protocol),适用于开发应用层通信消息,需要工作在GTP协议或MQ之上,支持消息判重、自定义消息、自定义可变类型等特性。
Index ¶
- Variables
- func Marshal[T MsgReader](msg T) (ret binaryutil.RecycleBytes, err error)
- func Unmarshal[T MsgWriter](msg T, data []byte) error
- type IMsgCreator
- type Msg
- type MsgForward
- type MsgHead
- type MsgId
- type MsgOnewayRPC
- type MsgPacket
- type MsgRPCReply
- type MsgRPCRequest
- type MsgReader
- type MsgWriter
- type SerializedMsg
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrGAP = errors.New("gap") // 消息协议错误
)
View Source
var (
ErrNotDeclared = fmt.Errorf("%w: msg not declared", ErrGAP) // 消息未注册
)
Functions ¶
func Marshal ¶ added in v0.1.36
func Marshal[T MsgReader](msg T) (ret binaryutil.RecycleBytes, err error)
Marshal 序列化
Types ¶
type IMsgCreator ¶
type IMsgCreator interface {
// Declare 注册消息
Declare(msg Msg)
// Undeclare 取消注册消息
Undeclare(msgId MsgId)
// New 创建消息指针
New(msgId MsgId) (Msg, error)
}
IMsgCreator 消息对象构建器接口
type MsgForward ¶ added in v0.1.32
type MsgForward struct {
Transit string // 中转地址
Dst string // 目标地址
CorrId int64 // 关联Id,用于支持Future等异步模型
TransId MsgId // 传输消息Id
TransData []byte // 传输消息内容(引用)
}
MsgForward 转发
type MsgHead ¶
type MsgHead struct {
Len uint32 // 消息长度
MsgId MsgId // 消息Id
Svc string // 来源服务
Src string // 来源地址
Seq int64 // 序号
}
MsgHead 消息头
type MsgOnewayRPC ¶ added in v0.2.38
type MsgOnewayRPC struct {
CallChain variant.CallChain // 调用链
Path []byte // 调用路径
Args variant.Array // 参数列表
}
MsgOnewayRPC 单程RPC请求
type MsgRPCReply ¶
type MsgRPCReply struct {
CorrId int64 // 关联Id,用于支持Future等异步模型
Rets variant.Array // 调用结果
Error variant.Error // 调用错误
}
MsgRPCReply RPC答复
type MsgRPCRequest ¶
type MsgRPCRequest struct {
CorrId int64 // 关联Id,用于支持Future等异步模型
CallChain variant.CallChain // 调用链
Path []byte // 调用路径
Args variant.Array // 参数列表
}
MsgRPCRequest RPC请求
type SerializedMsg ¶ added in v0.2.17
SerializedMsg 已序列化消息
Source Files
¶
Click to show internal directories.
Click to hide internal directories.