header

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// MaxHeaderSize = 4 + 2 + 2 + 2 + 10 + 10 + 10 + 10 + 10 + 10 + 4 (10 refer to binary.MaxVarintLen64)
	MaxHeaderSize = 74
	//防止链接异常,传入的第一个数字过大,导致耗尽系统资源,已经遇到过该问题,所以修复
	FrozeMaxHeaderSize = MaxHeaderSize + 100 + 100 + 100 + 100 //固定最大header长度,超过这个长度就属于异常数据
)

Variables

This section is empty.

Functions

func Release

func Release(h *Header)

Types

type Header struct {
	sync.RWMutex
	Version      uint32
	Type         headertype.Type
	CoderType    coder.CoderType
	CompressType compressor.CompressType
	FromService  string //来源服务器
	ToService    string //目的服务器
	Module       string
	Method       string
	Seq          uint64
	BodyLen      uint64
	Checksum     uint32
}

Header request header structure looks like: +---------+----------+---------+------------+-------------------+-----------------+-------------------+-----------------+----------+------------+----------+ | Version |HeaderType|CoderType|CompressType| FromService | ToService | Module | Method | Seq | RequestLen | Checksum | +---------+----------+---------+------------+-------------------+-----------------+-------------------+-----------------+----------+------------+----------+ | uint32 | uint16 | uint16 | uint16 | uvarint+ string | uvarint+ string | uvarint + string | uvarint +string | uvarint | uvarint | uint32 | +---------+----------+---------+------------+-------------------+-----------------+-------------------+-----------------+----------+------------+----------+

func Get

func Get() *Header

func (*Header) GetCoderType

func (r *Header) GetCoderType() coder.CoderType

func (*Header) GetCompressType

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

func (*Header) InitData

func (this *Header) InitData(v uint32, t headertype.Type, coderT coder.CoderType, compressT compressor.CompressType, from_service, to_service, module, method string, seq uint64)

func (*Header) InitVersionType

func (this *Header) InitVersionType(v uint32, t headertype.Type)

func (*Header) Marshal

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

Marshal will encode request header into a byte slice

func (*Header) Release

func (r *Header) Release()

func (*Header) Reset

func (r *Header) Reset()

func (*Header) Unmarshal

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

Unmarshal will decode request header into a byte slice

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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