codec

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPacket 表示 packet 头部缺失或字段组合非法。
	ErrInvalidPacket = errors.New("invalid proxy packet")
	// ErrInvalidBody 表示 MsgHead.len 与实际 body 长度不一致。
	ErrInvalidBody = errors.New("invalid proxy packet body length")
)

Functions

func DecodePacket

func DecodePacket(data []byte) (*proxypb.MsgHead, []byte, error)

DecodePacket 从 protobuf(MsgHead)+body 的线格式解出结构化头和 body。

func EncodeMessage

func EncodeMessage(msg rpc.Message) ([][]byte, error)

EncodeMessage 将 RPC 下行消息编码为 packet;RPCError body 由错误 Header 生成。

func EncodePacket

func EncodePacket(head *proxypb.MsgHead, body []byte) ([][]byte, error)

EncodePacket 将 MsgHead 和 body 编码为 protobuf(MsgHead)+body 的线格式。

func HeadFromMessage

func HeadFromMessage(msg rpc.Message) (*proxypb.MsgHead, error)

HeadFromMessage 将 RPC 下行消息转成 MsgHead,供客户端 packet 编码使用。

func IsClientTopic

func IsClientTopic(topic string) bool

IsClientTopic 判断 topic 是否符合客户端上行协议名规则。

func MessageFromPacket

func MessageFromPacket(head *proxypb.MsgHead, body []byte) (rpc.Message, error)

MessageFromPacket 将 packet 转成 rpc.Message,并还原 RPCError 的错误 Header。

func ValidateClientTopic

func ValidateClientTopic(topic string) error

ValidateClientTopic 校验客户端上行协议名。

Types

This section is empty.

Jump to

Keyboard shortcuts

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