header

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 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

	Uint32Size = 4
	Uint16Size = 2
)

Variables

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

Functions

This section is empty.

Types

type CompressType added in v0.2.0

type CompressType uint16

CompressType type of compressions supported by rpc

type RequestHeader

type RequestHeader struct {
	sync.RWMutex
	CompressType 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 added in v0.2.0

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 added in v0.2.0

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

Unmarshal will decode request header into a byte slice

type ResponseHeader

type ResponseHeader struct {
	sync.RWMutex
	CompressType 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 added in v0.2.0

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 added in v0.2.0

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