Documentation
¶
Index ¶
- Constants
- func Release(h *Header)
- type Header
- func (h *Header) GetMarshalType() coder.T
- func (r *Header) Marshal() []byte
- func (r *Header) Release()
- func (r *Header) Reset()
- func (this *Header) SetBodyLen(s uint64) *Header
- func (this *Header) SetChecksum(s uint32) *Header
- func (this *Header) SetCompressT(t compressor.T) *Header
- func (this *Header) SetFromService(s string) *Header
- func (this *Header) SetMataLen(s uint32) *Header
- func (this *Header) SetMetaCoderT(t coder.T) *Header
- func (this *Header) SetMethod(s string) *Header
- func (this *Header) SetModule(s string) *Header
- func (this *Header) SetReqCoderT(t coder.T) *Header
- func (this *Header) SetResCoderT(t coder.T) *Header
- func (this *Header) SetSeq(s uint64) *Header
- func (this *Header) SetToService(s string) *Header
- func (this *Header) SetType(t headertype.T) *Header
- func (this *Header) SetVersion(v uint32) *Header
- func (r *Header) Unmarshal(data []byte) (err error)
Constants ¶
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 ¶
Types ¶
type Header ¶
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 (*Header) GetMarshalType ¶ added in v2.0.1
func (*Header) SetBodyLen ¶ added in v2.0.1
func (*Header) SetChecksum ¶ added in v2.0.1
func (*Header) SetCompressT ¶ added in v2.0.1
func (this *Header) SetCompressT(t compressor.T) *Header