message

package
v0.0.0-...-18f1ea7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeReq

func EncodeReq(req *Request) []byte

func EncodeResp

func EncodeResp(resp *Response) []byte

Types

type Request

type Request struct {
	HeaderLength uint32 // 协议头长度
	BodyLength   uint32 // 协议体长度
	RequestID    uint32 // 消息ID
	Version      uint8  // 版本
	Compressor   uint8  // 压缩算法
	Serializer   uint8  // 序列化协议

	ServiceName string // 服务名
	MethodName  string // 方法名

	Meta map[string]string // 扩展字段,用于传递自定义元数据

	Data []byte // 协议体
}

func DecodeReq

func DecodeReq(data []byte) *Request

func (*Request) CalculateBodyLength

func (req *Request) CalculateBodyLength()

func (*Request) CalculateHeaderLength

func (req *Request) CalculateHeaderLength()

type Response

type Response struct {
	HeaderLength uint32 // 协议头长度
	BodyLength   uint32 // 协议体长度
	RequestID    uint32 // 消息ID
	Version      uint8  // 版本
	Compressor   uint8  // 压缩算法
	Serializer   uint8  // 序列化协议

	Error []byte // 错误信息

	Data []byte // 响应数据
}

func DecodeResp

func DecodeResp(data []byte) *Response

func (*Response) CalculateBodyLength

func (resp *Response) CalculateBodyLength()

func (*Response) CalculateHeaderLength

func (resp *Response) CalculateHeaderLength()

Jump to

Keyboard shortcuts

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