header

package
v0.0.0-...-d341122 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxHeaderSize = 2 + 10 + 10 + 10 + 4 (10 refer to binary.MaxVarintLen64)
	MaxHeaderSize = 36

	Uint16Size = 2
	Uint32Size = 4
)

Variables

View Source
var (
	RequestPool  sync.Pool
	ResponsePool sync.Pool
)
View Source
var ErrUnmarshal = errors.New("an error occurred in Unmarshal")

Functions

This section is empty.

Types

type RequestHeader

type RequestHeader struct {
	sync.RWMutex
	CompressType compressor.CompressType
	Method       string
	ID           uint64
	RequestLen   uint32
	Checksum     uint32
}

RequestHeader request header structure looks like: +--------------+----------------+----------+------------+----------+ | CompressType | Method | ID | RequestLen | Checksum | +--------------+----------------+----------+------------+----------+ | uint16 | uvarint+string | uvarint | uvarint | uint32 | +--------------+----------------+----------+------------+----------+

func (*RequestHeader) GetCompressType

func (r *RequestHeader) GetCompressType() compressor.CompressType

GetCompressType get compress type

func (*RequestHeader) Marshal

func (r *RequestHeader) Marshal() []byte

Marshal will encode request header into a byte slice

func (*RequestHeader) ResetHeader

func (r *RequestHeader) ResetHeader()

ResetHeader reset request header

func (*RequestHeader) Unmarshal

func (r *RequestHeader) Unmarshal(data []byte) (err error)

type ResponseHeader

type ResponseHeader struct {
	sync.RWMutex
	CompressType compressor.CompressType
	ID           uint64
	Error        string
	ResponseLen  uint32
	Checksum     uint32
}

ResponseHeader request header structure looks like: +--------------+---------+----------------+-------------+----------+ | CompressType | ID | Error | ResponseLen | Checksum | +--------------+---------+----------------+-------------+----------+ | uint16 | uvarint | uvarint+string | uvarint | uint32 | +--------------+---------+----------------+-------------+----------+

func (*ResponseHeader) GetCompressType

func (r *ResponseHeader) GetCompressType() compressor.CompressType

GetCompressType get compress type

func (*ResponseHeader) Marshal

func (r *ResponseHeader) Marshal() []byte

Marshal will encode response header into a byte slice

func (*ResponseHeader) ResetHeader

func (r *ResponseHeader) ResetHeader()

ResetHeader reset response header

func (*ResponseHeader) Unmarshal

func (r *ResponseHeader) Unmarshal(data []byte) (err error)

Unmarshal will decode response header into a byte slice

Jump to

Keyboard shortcuts

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