Documentation ¶
Index ¶
- Constants
- func Release(h *Header)
- type Header
- func (r *Header) GetCoderType() coder.CoderType
- func (r *Header) GetCompressType() compressor.CompressType
- func (this *Header) InitData(v uint32, t headertype.Type, coderT coder.CoderType, ...)
- func (this *Header) InitVersionType(v uint32, t headertype.Type)
- func (r *Header) Marshal() []byte
- func (r *Header) Release()
- func (r *Header) Reset()
- func (r *Header) Unmarshal(data []byte) (err error)
Constants ¶
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 ¶
Types ¶
type Header ¶
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 (*Header) GetCoderType ¶
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)