Documentation ¶
Overview ¶
codec
Index ¶
- Constants
- func RegisterCompressor(name string, compressor Compressor)
- func RegisterMarshaler(name string, marshaller Marshaler)
- type Codec
- type Compressor
- type GzipCompressor
- type JsonMarshaler
- type Marshaler
- type MsgpackMarshaler
- type ProtobufMarshaler
- type RawDataCompressor
- type SnappyCompressor
- type ThriftMarshaler
Constants ¶
View Source
const ( Json = "Json" Protobuf = "Protobuf" Thrift = "Thrift" Msgpack = "MessagePack" Gob = "Gob" )
Variables ¶
This section is empty.
Functions ¶
func RegisterCompressor ¶
func RegisterCompressor(name string, compressor Compressor)
RegisterCompressor
func RegisterMarshaler ¶
RegisterMarshaller
Types ¶
type Codec ¶
type Codec interface { // Encode Encode(req interface{}) ([]byte, error) // Decode Decode(req, rsp interface{}) error }
Codec Interface
type Compressor ¶
type Compressor interface { // Zip Zip(v interface{}) ([]byte, error) // Unzip Unzip(data []byte, v interface{}) error }
Compressor
type JsonMarshaler ¶
type JsonMarshaler struct{}
JsonMarshaler
func (*JsonMarshaler) Marshal ¶
func (jm *JsonMarshaler) Marshal(v interface{}) ([]byte, error)
Marshal
func (*JsonMarshaler) Unmarshal ¶
func (jm *JsonMarshaler) Unmarshal(data []byte, v interface{}) error
Unmarshal
type Marshaler ¶
type Marshaler interface { // Marshal Marshal(v interface{}) ([]byte, error) // Unmarshal Unmarshal(data []byte, v interface{}) error }
Marshaler encode/decode go struct
func GetMarshaler ¶
type MsgpackMarshaler ¶
type MsgpackMarshaler struct{}
MsgpackMarshaler
func (*MsgpackMarshaler) Marshal ¶
func (mm *MsgpackMarshaler) Marshal(v interface{}) ([]byte, error)
func (*MsgpackMarshaler) Unmarshal ¶
func (mm *MsgpackMarshaler) Unmarshal(data []byte, v interface{}) error
type ProtobufMarshaler ¶
type ProtobufMarshaler struct{}
ProtobufMarshaler
func (*ProtobufMarshaler) Marshal ¶
func (s *ProtobufMarshaler) Marshal(body interface{}) ([]byte, error)
Marshal
func (*ProtobufMarshaler) Unmarshal ¶
func (s *ProtobufMarshaler) Unmarshal(in []byte, body interface{}) error
/ Unmarshal 反序列protobuf
type RawDataCompressor ¶
type RawDataCompressor struct { }
type SnappyCompressor ¶
type SnappyCompressor struct{}
SnappyCompressor implements snappy compressor
type ThriftMarshaler ¶
type ThriftMarshaler struct{}
ThriftMarshaler
func (*ThriftMarshaler) Marshal ¶
func (tm *ThriftMarshaler) Marshal(v interface{}) ([]byte, error)
func (*ThriftMarshaler) Unmarshal ¶
func (tm *ThriftMarshaler) Unmarshal(data []byte, v interface{}) error
Click to show internal directories.
Click to hide internal directories.