Documentation
¶
Overview ¶
Package gap Golaxy应用层协议(golaxy application protocol),适用于开发应用层通信消息,需要工作在GTP协议或MQ之上,支持消息判重,解决了幂等性问题。
- 可以实现消息(Msg)接口新增自定义消息。
- 支持可变类型(Variant),提供了一些常用的内置类型,也可以实现可变类型值(variant.Value)接口,新增自定义类型。
- 支持自己实现消息(Msg)接口或可变类型值(variant.Value)接口,扩展支持protobuf(Protocol Buffers)等消息结构。
- 支持消息判重,解决幂等性问题。
Index ¶
- Variables
- func Marshal[T MsgReader](msg T) (binaryutil.RecycleBytes, error)
- func Unmarshal[T MsgWriter](msg T, data []byte) error
- type IMsgCreator
- type Msg
- type MsgBuff
- type MsgForward
- type MsgHead
- type MsgId
- type MsgOneWayRPC
- type MsgPacket
- type MsgRPCReply
- type MsgRPCRequest
- type MsgReader
- type MsgWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotDeclared = errors.New("gap: msg not declared") // 消息未注册
)
Functions ¶
func Marshal ¶ added in v0.1.36
func Marshal[T MsgReader](msg T) (binaryutil.RecycleBytes, error)
Types ¶
type IMsgCreator ¶
type IMsgCreator interface {
// Declare 注册消息
Declare(msg Msg)
// Undeclare 取消注册消息
Undeclare(msgId MsgId)
// New 创建消息指针
New(msgId MsgId) (Msg, error)
}
IMsgCreator 消息对象构建器接口
type MsgBuff ¶ added in v0.1.93
MsgBuff msg buff
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 ¶
type MsgOneWayRPC struct {
CallChain variant.CallChain // 调用链
Path string // 调用路径
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 string // 调用路径
Args variant.Array // 参数列表
}
MsgRPCRequest RPC请求
Source Files
¶
Click to show internal directories.
Click to hide internal directories.