message

package
v0.0.0-...-062a4ee Latest Latest
Warning

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

Go to latest
Published: Dec 18, 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 {
	// 头部
	HeadLength uint32 // 消息长度
	BodyLength uint32 // 协议版本
	RequestID  uint32 // 消息ID
	Version    uint8  // 版本
	Compresser uint8  // 压缩算法
	Serializer uint8  // 序列化协议
	// 服务名和方法名
	ServiceName string
	MethodName  string
	// 扩展字段,由于传递自定义元数据
	Meta map[string]string
	// 协议体
	Data []byte
}

func DecodeReq

func DecodeReq(data []byte) *Request

func (*Request) CalBodyLen

func (req *Request) CalBodyLen()

func (*Request) CalHeaderLen

func (req *Request) CalHeaderLen()

type Response

type Response struct {
	// 头部
	HeadLength uint32 // 消息长度
	BodyLength uint32 // 协议版本
	RequestID  uint32 // 消息ID
	Version    uint8  // 版本
	Compresser uint8  // 压缩算法
	Serializer uint8  // 序列化协议
	Error      []byte
	Data       []byte
}

func DecodeResp

func DecodeResp(data []byte) *Response

func (*Response) CalBodyLength

func (resp *Response) CalBodyLength()

func (*Response) CalHeaderLength

func (resp *Response) CalHeaderLength()

Jump to

Keyboard shortcuts

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