header

package
v2.0.17 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func Release

func Release(h *Header)

Types

type Header struct {
	Version     uint32
	Type        headertype.T
	MetaCoderT  coder.T //meta coder //body在使用场景的情况下可能使用json,但是meta可能追求性能使用msgp来序列化
	ReqCoderT   coder.T //req coder //类似的文件发送,发送是filebody的序列化,返回值可能是json序列化
	ResCoderT   coder.T //res coder
	CompressT   compressor.T
	FromService string //来源服务器
	ToService   string //目的服务器
	Module      string
	Method      string
	Seq         uint64
	MetaLen     uint32 //meta data长度
	BodyLen     uint64
	Checksum    uint32
}

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

func Get

func Get() *Header

func (*Header) GetMarshalType added in v2.0.1

func (h *Header) GetMarshalType() coder.T

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) SetBodyLen added in v2.0.1

func (this *Header) SetBodyLen(s uint64) *Header

func (*Header) SetChecksum added in v2.0.1

func (this *Header) SetChecksum(s uint32) *Header

func (*Header) SetCompressT added in v2.0.1

func (this *Header) SetCompressT(t compressor.T) *Header

func (*Header) SetFromService added in v2.0.1

func (this *Header) SetFromService(s string) *Header

func (*Header) SetMataLen added in v2.0.1

func (this *Header) SetMataLen(s uint32) *Header

func (*Header) SetMetaCoderT added in v2.0.1

func (this *Header) SetMetaCoderT(t coder.T) *Header

func (*Header) SetMethod added in v2.0.1

func (this *Header) SetMethod(s string) *Header

func (*Header) SetModule added in v2.0.1

func (this *Header) SetModule(s string) *Header

func (*Header) SetReqCoderT added in v2.0.1

func (this *Header) SetReqCoderT(t coder.T) *Header

func (*Header) SetResCoderT added in v2.0.1

func (this *Header) SetResCoderT(t coder.T) *Header

func (*Header) SetSeq added in v2.0.1

func (this *Header) SetSeq(s uint64) *Header

func (*Header) SetToService added in v2.0.1

func (this *Header) SetToService(s string) *Header

func (*Header) SetType added in v2.0.1

func (this *Header) SetType(t headertype.T) *Header

func (*Header) SetVersion added in v2.0.1

func (this *Header) SetVersion(v uint32) *Header

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