Documentation ¶
Index ¶
Constants ¶
const ( // MaxHeaderSize = 2 + 10 + 10 + 10 + 4 (10 refer to binary.MaxVarintLen64) MaxHeaderSize = 36 Uint32Size = 4 Uint16Size = 2 )
Variables ¶
var ( RequestPool sync.Pool ResponsePool sync.Pool )
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 { 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) 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 { 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) 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