Documentation ¶
Index ¶
- func IsThriftCodec(c remote.PayloadCodec) bool
- func MarshalThriftData(ctx context.Context, codec remote.PayloadCodec, data interface{}) ([]byte, error)
- func NewBinaryProtocol(t remote.ByteBuffer) *athrift.BinaryProtocol
- 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 athrift.TProtocol) error
- type BinaryProtocol
- type CodecType
- type MessageReader
- type MessageWriter
- 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) NOTE: it's used by grpc only, coz kitex grpc doesn't implements remote.Message and remote.ByteBuffer for rpc.
for `FastWrite` or `FrugalWrite`, the buf is created by `github.com/bytedance/gopkg/lang/mcache`, `Free` it at your own risk.
for internals, actually, coz it's hard to control the lifecycle of a returned buf, we use a safe version of `mcache` which is compatible with `mcache` to make sure `Free` would not have any side effects. see `github.com/cloudwego/kitex/internal/utils/safemcache` for details.
func NewBinaryProtocol ¶
func NewBinaryProtocol(t remote.ByteBuffer) *athrift.BinaryProtocol
NewBinaryProtocol ... Deprecated: use github.com/apache/thrift/lib/go/thrift.NewTBinaryProtocol
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: `method` is required for generic calls
func UnmarshalThriftException ¶ added in v0.9.0
UnmarshalThriftException decode thrift exception from tProt TODO: this func should be removed in the future. it's exposed accidentally. Deprecated: Use `SkipDecoder` + `ApplicationException` of `cloudwego/gopkg/protocol/thrift` instead.
Types ¶
type BinaryProtocol ¶
type BinaryProtocol = athrift.BinaryProtocol
BinaryProtocol ... Deprecated: use github.com/apache/thrift/lib/go/thrift.NewTBinaryProtocol
type CodecType ¶ added in v0.3.3
type CodecType int
CodecType is config of the thrift codec. Priority: Frugal > FastMode > Normal
const ( // Basic can be used for disabling fastCodec and frugal Basic CodecType = 0b0000 FastWrite CodecType = 0b0001 FastRead CodecType = 0b0010 FastReadWrite = FastRead | FastWrite FrugalWrite CodecType = 0b0100 FrugalRead CodecType = 0b1000 FrugalReadWrite = FrugalWrite | FrugalRead EnableSkipDecoder CodecType = 0b10000 )
type MessageReader ¶
MessageReader read from athrift.TProtocol Deprecated: use github.com/apache/thrift/lib/go/thrift.TStruct
type MessageWriter ¶
MessageWriter write to athrift.TProtocol Deprecated: use github.com/apache/thrift/lib/go/thrift.TStruct
type ThriftMsgFastCodec ¶ added in v0.4.4
ThriftMsgFastCodec ... Deprecated: use `github.com/cloudwego/gopkg/protocol/thrift.FastCodec`