Documentation ¶
Index ¶
- func IsThriftCodec(c remote.PayloadCodec) bool
- func MarshalThriftData(ctx context.Context, codec remote.PayloadCodec, data interface{}) ([]byte, error)
- func NewThriftCodec() remote.PayloadCodec
- func NewThriftCodecDisableFastMode(disableFastWrite, disableFastRead bool) remote.PayloadCodec
- func NewThriftCodecWithConfig(c CodecType) remote.PayloadCodec
- func UnmarshalThriftData(ctx context.Context, codec remote.PayloadCodec, method string, buf []byte, ...) error
- func UnmarshalThriftException(tProt thrift.TProtocol) error
- type BinaryProtocol
- func (p *BinaryProtocol) ByteBuffer() remote.ByteBuffer
- func (p *BinaryProtocol) Flush(ctx context.Context) (err error)
- func (p *BinaryProtocol) ReadBinary() ([]byte, error)
- func (p *BinaryProtocol) ReadBool() (bool, error)
- func (p *BinaryProtocol) ReadByte() (value int8, err error)
- func (p *BinaryProtocol) ReadDouble() (value float64, err error)
- func (p *BinaryProtocol) ReadFieldBegin() (name string, typeID thrift.TType, id int16, err error)
- func (p *BinaryProtocol) ReadFieldEnd() error
- func (p *BinaryProtocol) ReadI16() (value int16, err error)
- func (p *BinaryProtocol) ReadI32() (value int32, err error)
- func (p *BinaryProtocol) ReadI64() (value int64, err error)
- func (p *BinaryProtocol) ReadListBegin() (elemType thrift.TType, size int, err error)
- func (p *BinaryProtocol) ReadListEnd() error
- func (p *BinaryProtocol) ReadMapBegin() (kType, vType thrift.TType, size int, err error)
- func (p *BinaryProtocol) ReadMapEnd() error
- func (p *BinaryProtocol) ReadMessageBegin() (name string, typeID thrift.TMessageType, seqID int32, err error)
- func (p *BinaryProtocol) ReadMessageEnd() error
- func (p *BinaryProtocol) ReadSetBegin() (elemType thrift.TType, size int, err error)
- func (p *BinaryProtocol) ReadSetEnd() error
- func (p *BinaryProtocol) ReadString() (value string, err error)
- func (p *BinaryProtocol) ReadStructBegin() (name string, err error)
- func (p *BinaryProtocol) ReadStructEnd() error
- func (p *BinaryProtocol) Recycle()
- func (p *BinaryProtocol) Skip(fieldType thrift.TType) (err error)
- func (p *BinaryProtocol) Transport() thrift.TTransport
- func (p *BinaryProtocol) WriteBinary(value []byte) error
- func (p *BinaryProtocol) WriteBool(value bool) error
- func (p *BinaryProtocol) WriteByte(value int8) error
- func (p *BinaryProtocol) WriteDouble(value float64) error
- func (p *BinaryProtocol) WriteFieldBegin(name string, typeID thrift.TType, id int16) error
- func (p *BinaryProtocol) WriteFieldEnd() error
- func (p *BinaryProtocol) WriteFieldStop() error
- func (p *BinaryProtocol) WriteI16(value int16) error
- func (p *BinaryProtocol) WriteI32(value int32) error
- func (p *BinaryProtocol) WriteI64(value int64) error
- func (p *BinaryProtocol) WriteListBegin(elemType thrift.TType, size int) error
- func (p *BinaryProtocol) WriteListEnd() error
- func (p *BinaryProtocol) WriteMapBegin(keyType, valueType thrift.TType, size int) error
- func (p *BinaryProtocol) WriteMapEnd() error
- func (p *BinaryProtocol) WriteMessageBegin(name string, typeID thrift.TMessageType, seqID int32) error
- func (p *BinaryProtocol) WriteMessageEnd() error
- func (p *BinaryProtocol) WriteSetBegin(elemType thrift.TType, size int) error
- func (p *BinaryProtocol) WriteSetEnd() error
- func (p *BinaryProtocol) WriteString(value string) error
- func (p *BinaryProtocol) WriteStructBegin(name string) error
- func (p *BinaryProtocol) WriteStructEnd() error
- type CodecType
- type MessageReader
- type MessageReaderWithMethodWithContext
- type MessageWriter
- type MessageWriterWithContext
- type ThriftMsgFastCodec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsThriftCodec ¶ added in v0.9.0
func IsThriftCodec(c remote.PayloadCodec) bool
IsThriftCodec checks if the codec is thriftCodec
func MarshalThriftData ¶ added in v0.9.0
func MarshalThriftData(ctx context.Context, codec remote.PayloadCodec, data interface{}) ([]byte, error)
MarshalThriftData only encodes the data (without the prepending methodName, msgType, seqId) It will allocate a new buffer and encode to it
func NewThriftCodec ¶
func NewThriftCodec() remote.PayloadCodec
NewThriftCodec creates the thrift binary codec.
func NewThriftCodecDisableFastMode ¶ added in v0.1.0
func NewThriftCodecDisableFastMode(disableFastWrite, disableFastRead bool) remote.PayloadCodec
NewThriftCodecDisableFastMode creates the thrift binary codec which can control if do fast codec. Eg: xxxservice.NewServer(handler, server.WithPayloadCodec(thrift.NewThriftCodecDisableFastMode(true, true)))
func NewThriftCodecWithConfig ¶ added in v0.3.3
func NewThriftCodecWithConfig(c CodecType) remote.PayloadCodec
NewThriftFrugalCodec creates the thrift binary codec powered by frugal. Eg: xxxservice.NewServer(handler, server.WithPayloadCodec(thrift.NewThriftCodecWithConfig(thrift.FastWrite | thrift.FastRead)))
func UnmarshalThriftData ¶ added in v0.9.0
func UnmarshalThriftData(ctx context.Context, codec remote.PayloadCodec, method string, buf []byte, data interface{}) error
UnmarshalThriftData only decodes the data (after methodName, msgType and seqId) It will decode from the given buffer. Note: 1. `method` is only used for generic calls 2. if the buf contains an exception, you should call UnmarshalThriftException instead.
func UnmarshalThriftException ¶ added in v0.9.0
UnmarshalThriftException decode thrift exception from tProt If your input is []byte, you can wrap it with `NewBinaryProtocol(remote.NewReaderBuffer(buf))`
Types ¶
type BinaryProtocol ¶
type BinaryProtocol struct {
// contains filtered or unexported fields
}
BinaryProtocol ...
func NewBinaryProtocol ¶
func NewBinaryProtocol(t remote.ByteBuffer) *BinaryProtocol
NewBinaryProtocol ...
func (*BinaryProtocol) ByteBuffer ¶ added in v0.7.0
func (p *BinaryProtocol) ByteBuffer() remote.ByteBuffer
ByteBuffer ...
func (*BinaryProtocol) Flush ¶
func (p *BinaryProtocol) Flush(ctx context.Context) (err error)
Flush ...
func (*BinaryProtocol) ReadBinary ¶
func (p *BinaryProtocol) ReadBinary() ([]byte, error)
ReadBinary ...
func (*BinaryProtocol) ReadByte ¶
func (p *BinaryProtocol) ReadByte() (value int8, err error)
ReadByte ...
func (*BinaryProtocol) ReadDouble ¶
func (p *BinaryProtocol) ReadDouble() (value float64, err error)
ReadDouble ...
func (*BinaryProtocol) ReadFieldBegin ¶
ReadFieldBegin ...
func (*BinaryProtocol) ReadFieldEnd ¶
func (p *BinaryProtocol) ReadFieldEnd() error
ReadFieldEnd ...
func (*BinaryProtocol) ReadI16 ¶
func (p *BinaryProtocol) ReadI16() (value int16, err error)
ReadI16 ...
func (*BinaryProtocol) ReadI32 ¶
func (p *BinaryProtocol) ReadI32() (value int32, err error)
ReadI32 ...
func (*BinaryProtocol) ReadI64 ¶
func (p *BinaryProtocol) ReadI64() (value int64, err error)
ReadI64 ...
func (*BinaryProtocol) ReadListBegin ¶
func (p *BinaryProtocol) ReadListBegin() (elemType thrift.TType, size int, err error)
ReadListBegin ...
func (*BinaryProtocol) ReadMapBegin ¶
func (p *BinaryProtocol) ReadMapBegin() (kType, vType thrift.TType, size int, err error)
ReadMapBegin ...
func (*BinaryProtocol) ReadMessageBegin ¶
func (p *BinaryProtocol) ReadMessageBegin() (name string, typeID thrift.TMessageType, seqID int32, err error)
ReadMessageBegin ...
func (*BinaryProtocol) ReadMessageEnd ¶
func (p *BinaryProtocol) ReadMessageEnd() error
ReadMessageEnd ...
func (*BinaryProtocol) ReadSetBegin ¶
func (p *BinaryProtocol) ReadSetBegin() (elemType thrift.TType, size int, err error)
ReadSetBegin ...
func (*BinaryProtocol) ReadString ¶
func (p *BinaryProtocol) ReadString() (value string, err error)
ReadString ...
func (*BinaryProtocol) ReadStructBegin ¶
func (p *BinaryProtocol) ReadStructBegin() (name string, err error)
ReadStructBegin ...
func (*BinaryProtocol) ReadStructEnd ¶
func (p *BinaryProtocol) ReadStructEnd() error
ReadStructEnd ...
func (*BinaryProtocol) Skip ¶
func (p *BinaryProtocol) Skip(fieldType thrift.TType) (err error)
Skip ...
func (*BinaryProtocol) Transport ¶
func (p *BinaryProtocol) Transport() thrift.TTransport
Transport ...
func (*BinaryProtocol) WriteBinary ¶
func (p *BinaryProtocol) WriteBinary(value []byte) error
WriteBinary ...
func (*BinaryProtocol) WriteBool ¶
func (p *BinaryProtocol) WriteBool(value bool) error
WriteBool ...
func (*BinaryProtocol) WriteByte ¶
func (p *BinaryProtocol) WriteByte(value int8) error
WriteByte ...
func (*BinaryProtocol) WriteDouble ¶
func (p *BinaryProtocol) WriteDouble(value float64) error
WriteDouble ...
func (*BinaryProtocol) WriteFieldBegin ¶
WriteFieldBegin ...
func (*BinaryProtocol) WriteFieldEnd ¶
func (p *BinaryProtocol) WriteFieldEnd() error
WriteFieldEnd ...
func (*BinaryProtocol) WriteFieldStop ¶
func (p *BinaryProtocol) WriteFieldStop() error
WriteFieldStop ...
func (*BinaryProtocol) WriteListBegin ¶
func (p *BinaryProtocol) WriteListBegin(elemType thrift.TType, size int) error
WriteListBegin ...
func (*BinaryProtocol) WriteListEnd ¶
func (p *BinaryProtocol) WriteListEnd() error
WriteListEnd ...
func (*BinaryProtocol) WriteMapBegin ¶
func (p *BinaryProtocol) WriteMapBegin(keyType, valueType thrift.TType, size int) error
WriteMapBegin ...
func (*BinaryProtocol) WriteMessageBegin ¶
func (p *BinaryProtocol) WriteMessageBegin(name string, typeID thrift.TMessageType, seqID int32) error
WriteMessageBegin ...
func (*BinaryProtocol) WriteMessageEnd ¶
func (p *BinaryProtocol) WriteMessageEnd() error
WriteMessageEnd ...
func (*BinaryProtocol) WriteSetBegin ¶
func (p *BinaryProtocol) WriteSetBegin(elemType thrift.TType, size int) error
WriteSetBegin ...
func (*BinaryProtocol) WriteString ¶
func (p *BinaryProtocol) WriteString(value string) error
WriteString ...
func (*BinaryProtocol) WriteStructBegin ¶
func (p *BinaryProtocol) WriteStructBegin(name string) error
WriteStructBegin ...
func (*BinaryProtocol) WriteStructEnd ¶
func (p *BinaryProtocol) WriteStructEnd() error
WriteStructEnd ...
type CodecType ¶ added in v0.3.3
type CodecType int
CodecType is config of the thrift codec. Priority: Frugal > FastMode > Normal
const ( // 0b0001 and 0b0010 are used for FastWrite and FastRead, so Frugal starts from 0b0100 FrugalWrite CodecType = 0b0100 FrugalRead CodecType = 0b1000 FrugalReadWrite = FrugalWrite | FrugalRead )
type MessageReader ¶
MessageReader read from thrift.TProtocol
type MessageReaderWithMethodWithContext ¶
type MessageReaderWithMethodWithContext interface {
Read(ctx context.Context, method string, oprot thrift.TProtocol) error
}
MessageReaderWithMethodWithContext read from thrift.TProtocol with method
type MessageWriter ¶
MessageWriter write to thrift.TProtocol
type MessageWriterWithContext ¶
type MessageWriterWithContext interface {
Write(ctx context.Context, oprot thrift.TProtocol) error
}
MessageWriterWithContext write to thrift.TProtocol