Documentation
¶
Index ¶
- Variables
- func DecodePacket(data []byte) (*proxypb.MsgHead, []byte, error)
- func EncodeMessage(msg rpc.Message) ([][]byte, error)
- func EncodePacket(head *proxypb.MsgHead, body []byte) ([][]byte, error)
- func HeadFromMessage(msg rpc.Message) (*proxypb.MsgHead, error)
- func IsClientTopic(topic string) bool
- func MessageFromPacket(head *proxypb.MsgHead, body []byte) (rpc.Message, error)
- func ValidateClientTopic(topic string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPacket 表示 packet 头部缺失或字段组合非法。 ErrInvalidPacket = errors.New("invalid proxy packet") // ErrInvalidBody 表示 MsgHead.len 与实际 body 长度不一致。 ErrInvalidBody = errors.New("invalid proxy packet body length") )
Functions ¶
func DecodePacket ¶
DecodePacket 从 protobuf(MsgHead)+body 的线格式解出结构化头和 body。
func EncodeMessage ¶
EncodeMessage 将 RPC 下行消息编码为 packet;RPCError body 由错误 Header 生成。
func EncodePacket ¶
EncodePacket 将 MsgHead 和 body 编码为 protobuf(MsgHead)+body 的线格式。
func HeadFromMessage ¶
HeadFromMessage 将 RPC 下行消息转成 MsgHead,供客户端 packet 编码使用。
func MessageFromPacket ¶
MessageFromPacket 将 packet 转成 rpc.Message,并还原 RPCError 的错误 Header。
func ValidateClientTopic ¶
ValidateClientTopic 校验客户端上行协议名。
Types ¶
This section is empty.