Documentation ¶
Index ¶
- Constants
- Variables
- func GUNZIP(b []byte) ([]byte, error)
- func GZIP(b []byte) ([]byte, error)
- type Header
- type Package
- func (r *Package) Bytes() ([]byte, error)
- func (r *Package) GetMagicCode() string
- func (r *Package) GetTraceId() string
- func (r *Package) Load(b []byte) error
- func (r *Package) ReadIO(rw io.Reader) error
- func (r *Package) SetAttachment(Attachment []byte) *Package
- func (r *Package) SetAuthenticationData(authenticationData []byte) *Package
- func (r *Package) SetChunkInfo(streamId int64, chunkId int64) *Package
- func (r *Package) SetCompressType(compressType int32) *Package
- func (r *Package) SetCorrelationId(correlationId int64) *Package
- func (r *Package) SetData(Data []byte) *Package
- func (r *Package) SetErrorCode(errorCode int32) *Package
- func (r *Package) SetErrorText(errorText string) *Package
- func (r *Package) SetMagicCode(magicCode []byte) error
- func (r *Package) SetMethodName(methodName string) *Package
- func (r *Package) SetServiceName(serviceName string) *Package
- func (r *Package) SetTraceId(traceId string) *Package
- func (r *Package) WriteIO(rw io.Writer) (int, error)
Constants ¶
View Source
const ( COMPRESS_NO int32 = 0 COMPRESS_SNAPPY int32 = 1 COMPRESS_GZIP int32 = 2 HeaderSize = 12 MagicCode = "PRPC" )
Variables ¶
View Source
var ERR_IGNORE_ERR = errors.New("[marshal-001]Ingore error")
error log info definition
View Source
var ERR_META = errors.New("[marshal-003]Get nil value from Meta struct after marshal")
View Source
var ERR_NO_SNAPPY = errors.New("[marshal-002]Snappy compress not support yet.")
Functions ¶
Types ¶
type Header ¶
Header PbRPC header content
func (*Header) SetMagicCode ¶
SetMagicCode change magic code in header
type Package ¶
Data package for baidu RPC. all request and response data package should apply this.
----------------------------------- | Head | Meta | Data | Attachment | -----------------------------------
1. <Head> with fixed 12 byte length as follow format ---------------------------------------------- | PRPC | MessageSize(int32) | MetaSize(int32) | ---------------------------------------------- MessageSize = totalSize - 12(Fixed Head Size) MetaSize = Meta object size
2. <Meta> body proto description as follow
message RpcMeta { optional RpcRequestMeta request = 1; optional RpcResponseMeta response = 2; optional int32 compress_type = 3; // 0:nocompress 1:Snappy 2:gzip optional int64 correlation_id = 4; optional int32 attachment_size = 5; optional ChunkInfo chuck_info = 6; optional bytes authentication_data = 7; };
message Request { required string service_name = 1; required string method_name = 2; optional int64 log_id = 3; };
message Response { optional int32 error_code = 1; optional string error_text = 2; };
messsage ChunkInfo { required int64 stream_id = 1; required int64 chunk_id = 2; };
3. <Data> customize transport data message.
4. <Attachment> attachment body data message
func NewPackage ¶
func NewPackage() *Package
func NewRequestPackage ¶
func NewRequestPackage() *Package
func NewResponsePackage ¶
func NewResponsePackage() *Package
func (*Package) GetMagicCode ¶
func (*Package) GetTraceId ¶
func (*Package) SetAttachment ¶
func (*Package) SetAuthenticationData ¶
func (*Package) SetChunkInfo ¶
func (*Package) SetCompressType ¶
func (*Package) SetCorrelationId ¶
func (*Package) SetErrorCode ¶
func (*Package) SetErrorText ¶
func (*Package) SetMagicCode ¶
func (*Package) SetMethodName ¶
func (*Package) SetServiceName ¶
func (*Package) SetTraceId ¶
Click to show internal directories.
Click to hide internal directories.