thrift

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 11 Imported by: 72

Documentation

Index

Constants

View Source
const (
	UNKNOWN_APPLICATION_EXCEPTION  = 0
	UNKNOWN_METHOD                 = 1
	INVALID_MESSAGE_TYPE_EXCEPTION = 2
	WRONG_METHOD_NAME              = 3
	BAD_SEQUENCE_ID                = 4
	MISSING_RESULT                 = 5
	INTERNAL_ERROR                 = 6
	PROTOCOL_ERROR                 = 7
	INVALID_TRANSFORM              = 8
	INVALID_PROTOCOL               = 9
	UNSUPPORTED_CLIENT_TYPE        = 10
)
View Source
const (
	UNKNOWN_PROTOCOL_EXCEPTION = 0
	INVALID_DATA               = 1
	NEGATIVE_SIZE              = 2
	SIZE_LIMIT                 = 3
	BAD_VERSION                = 4
	NOT_IMPLEMENTED            = 5
	DEPTH_LIMIT                = 6
)

Variables

This section is empty.

Functions

func FastMarshal

func FastMarshal(msg FastCodec) []byte

FastMarshal marshals the msg to buf. The msg should implement FastCodec.

func FastUnmarshal

func FastUnmarshal(buf []byte, msg FastCodec) error

FastUnmarshal unmarshal the buf into msg. The msg should implement FastCodec.

func MarshalFastMsg

func MarshalFastMsg(method string, msgType TMessageType, seq int32, msg FastCodec) ([]byte, error)

MarshalFastMsg encodes the given msg to buf for generic thrift RPC.

func PrependError

func PrependError(prepend string, err error) error

Prepends additional information to an error without losing the Thrift exception interface

func SetSpanCache added in v0.1.1

func SetSpanCache(enable bool)

SetSpanCache enable/disable binary protocol bytes/string allocator

func UnmarshalFastMsg

func UnmarshalFastMsg(b []byte, msg FastCodec) (method string, seq int32, err error)

UnmarshalFastMsg parses the given buf and stores the result to msg for generic thrift RPC. for EXCEPTION msgType, it will returns `err` with *ApplicationException type without storing the result to msg.

Types

type ApplicationException

type ApplicationException struct {
	// contains filtered or unexported fields
}

ApplicationException is for replacing apache.TApplicationException it implements ThriftFastCodec interface.

func NewApplicationException

func NewApplicationException(t int32, msg string) *ApplicationException

NewApplicationException creates an ApplicationException instance

func (*ApplicationException) BLength

func (e *ApplicationException) BLength() int

BLength returns the len of encoded buffer.

func (*ApplicationException) Error

func (e *ApplicationException) Error() string

Error ...

func (*ApplicationException) FastRead

func (e *ApplicationException) FastRead(b []byte) (off int, err error)

FastRead ...

func (*ApplicationException) FastWrite

func (e *ApplicationException) FastWrite(b []byte) (off int)

FastWrite ...

func (*ApplicationException) FastWriteNocopy

func (e *ApplicationException) FastWriteNocopy(b []byte, _ NocopyWriter) int

FastWriteNocopy ...

func (*ApplicationException) Msg

func (e *ApplicationException) Msg() string

Msg ...

func (*ApplicationException) String

func (e *ApplicationException) String() string

String ...

func (*ApplicationException) TypeID

func (e *ApplicationException) TypeID() int32

TypeID ... for kitex

func (*ApplicationException) TypeId

func (e *ApplicationException) TypeId() int32

TypeId ... for apache ApplicationException compatibility

type BinaryProtocol

type BinaryProtocol struct{}
var Binary BinaryProtocol

func (BinaryProtocol) AppendBinary

func (p BinaryProtocol) AppendBinary(buf, v []byte) []byte

func (BinaryProtocol) AppendBool

func (BinaryProtocol) AppendBool(buf []byte, v bool) []byte

func (BinaryProtocol) AppendByte

func (BinaryProtocol) AppendByte(buf []byte, v int8) []byte

func (BinaryProtocol) AppendDouble

func (BinaryProtocol) AppendDouble(buf []byte, v float64) []byte

func (BinaryProtocol) AppendFieldBegin

func (BinaryProtocol) AppendFieldBegin(buf []byte, typeID TType, id int16) []byte

func (BinaryProtocol) AppendFieldStop

func (BinaryProtocol) AppendFieldStop(buf []byte) []byte

func (BinaryProtocol) AppendI16

func (BinaryProtocol) AppendI16(buf []byte, v int16) []byte

func (BinaryProtocol) AppendI32

func (BinaryProtocol) AppendI32(buf []byte, v int32) []byte

func (BinaryProtocol) AppendI64

func (BinaryProtocol) AppendI64(buf []byte, v int64) []byte

func (BinaryProtocol) AppendListBegin

func (p BinaryProtocol) AppendListBegin(buf []byte, et TType, size int) []byte

func (BinaryProtocol) AppendMapBegin

func (p BinaryProtocol) AppendMapBegin(buf []byte, kt, vt TType, size int) []byte

func (BinaryProtocol) AppendMessageBegin

func (p BinaryProtocol) AppendMessageBegin(buf []byte, name string, typeID TMessageType, seq int32) []byte

func (BinaryProtocol) AppendSetBegin

func (p BinaryProtocol) AppendSetBegin(buf []byte, et TType, size int) []byte

func (BinaryProtocol) AppendString

func (p BinaryProtocol) AppendString(buf []byte, v string) []byte

func (BinaryProtocol) BinaryLength

func (BinaryProtocol) BinaryLength(v []byte) int

func (BinaryProtocol) BinaryLengthNocopy

func (BinaryProtocol) BinaryLengthNocopy(v []byte) int

func (BinaryProtocol) BoolLength

func (BinaryProtocol) BoolLength() int

func (BinaryProtocol) ByteLength

func (BinaryProtocol) ByteLength() int

func (BinaryProtocol) DoubleLength

func (BinaryProtocol) DoubleLength() int

func (BinaryProtocol) FieldBeginLength

func (BinaryProtocol) FieldBeginLength() int

func (BinaryProtocol) FieldStopLength

func (BinaryProtocol) FieldStopLength() int

func (BinaryProtocol) I16Length

func (BinaryProtocol) I16Length() int

func (BinaryProtocol) I32Length

func (BinaryProtocol) I32Length() int

func (BinaryProtocol) I64Length

func (BinaryProtocol) I64Length() int

func (BinaryProtocol) ListBeginLength

func (BinaryProtocol) ListBeginLength() int

func (BinaryProtocol) MapBeginLength

func (BinaryProtocol) MapBeginLength() int

func (BinaryProtocol) MessageBeginLength

func (BinaryProtocol) MessageBeginLength(method string) int

func (BinaryProtocol) ReadBinary

func (p BinaryProtocol) ReadBinary(buf []byte) (b []byte, l int, err error)

func (BinaryProtocol) ReadBool

func (BinaryProtocol) ReadBool(buf []byte) (v bool, l int, err error)

func (BinaryProtocol) ReadByte

func (BinaryProtocol) ReadByte(buf []byte) (v int8, l int, err error)

func (BinaryProtocol) ReadDouble

func (BinaryProtocol) ReadDouble(buf []byte) (v float64, l int, err error)

func (BinaryProtocol) ReadFieldBegin

func (BinaryProtocol) ReadFieldBegin(buf []byte) (typeID TType, id int16, l int, err error)

func (BinaryProtocol) ReadI16

func (BinaryProtocol) ReadI16(buf []byte) (v int16, l int, err error)

func (BinaryProtocol) ReadI32

func (BinaryProtocol) ReadI32(buf []byte) (v int32, l int, err error)

func (BinaryProtocol) ReadI64

func (BinaryProtocol) ReadI64(buf []byte) (v int64, l int, err error)

func (BinaryProtocol) ReadListBegin

func (BinaryProtocol) ReadListBegin(buf []byte) (et TType, size, l int, err error)

func (BinaryProtocol) ReadMapBegin

func (BinaryProtocol) ReadMapBegin(buf []byte) (kt, vt TType, size, l int, err error)

func (BinaryProtocol) ReadMessageBegin

func (p BinaryProtocol) ReadMessageBegin(buf []byte) (name string, typeID TMessageType, seq int32, l int, err error)

func (BinaryProtocol) ReadSetBegin

func (BinaryProtocol) ReadSetBegin(buf []byte) (et TType, size, l int, err error)

func (BinaryProtocol) ReadString

func (p BinaryProtocol) ReadString(buf []byte) (s string, l int, err error)

func (BinaryProtocol) SetBeginLength

func (BinaryProtocol) SetBeginLength() int

func (BinaryProtocol) Skip

func (BinaryProtocol) Skip(b []byte, t TType) (int, error)

Skip skips over the value for the given type using Go implementation.

func (BinaryProtocol) StringLength

func (BinaryProtocol) StringLength(v string) int

func (BinaryProtocol) StringLengthNocopy

func (BinaryProtocol) StringLengthNocopy(v string) int

func (BinaryProtocol) WriteBinary

func (BinaryProtocol) WriteBinary(buf, v []byte) int

func (BinaryProtocol) WriteBinaryNocopy

func (p BinaryProtocol) WriteBinaryNocopy(buf []byte, w NocopyWriter, v []byte) int

func (BinaryProtocol) WriteBool

func (BinaryProtocol) WriteBool(buf []byte, v bool) int

func (BinaryProtocol) WriteByte

func (BinaryProtocol) WriteByte(buf []byte, v int8) int

func (BinaryProtocol) WriteDouble

func (BinaryProtocol) WriteDouble(buf []byte, v float64) int

func (BinaryProtocol) WriteFieldBegin

func (BinaryProtocol) WriteFieldBegin(buf []byte, typeID TType, id int16) int

func (BinaryProtocol) WriteFieldStop

func (BinaryProtocol) WriteFieldStop(buf []byte) int

func (BinaryProtocol) WriteI16

func (BinaryProtocol) WriteI16(buf []byte, v int16) int

func (BinaryProtocol) WriteI32

func (BinaryProtocol) WriteI32(buf []byte, v int32) int

func (BinaryProtocol) WriteI64

func (BinaryProtocol) WriteI64(buf []byte, v int64) int

func (BinaryProtocol) WriteListBegin

func (BinaryProtocol) WriteListBegin(buf []byte, et TType, size int) int

func (BinaryProtocol) WriteMapBegin

func (BinaryProtocol) WriteMapBegin(buf []byte, kt, vt TType, size int) int

func (BinaryProtocol) WriteMessageBegin

func (BinaryProtocol) WriteMessageBegin(buf []byte, name string, typeID TMessageType, seq int32) int

func (BinaryProtocol) WriteSetBegin

func (BinaryProtocol) WriteSetBegin(buf []byte, et TType, size int) int

func (BinaryProtocol) WriteString

func (BinaryProtocol) WriteString(buf []byte, v string) int

func (BinaryProtocol) WriteStringNocopy

func (p BinaryProtocol) WriteStringNocopy(buf []byte, w NocopyWriter, v string) int

type BufferReader added in v0.1.1

type BufferReader struct {
	// contains filtered or unexported fields
}

BufferReader represents a reader for binary protocol

func NewBufferReader added in v0.1.1

func NewBufferReader(r bufiox.Reader) *BufferReader

NewBufferReader ... call Release if no longer use for reusing

func (*BufferReader) ReadBinary added in v0.1.1

func (r *BufferReader) ReadBinary() (b []byte, err error)

ReadBinary ...

func (*BufferReader) ReadBool added in v0.1.1

func (r *BufferReader) ReadBool() (v bool, err error)

ReadBool ...

func (*BufferReader) ReadByte added in v0.1.1

func (r *BufferReader) ReadByte() (v int8, err error)

ReadByte ...

func (*BufferReader) ReadDouble added in v0.1.1

func (r *BufferReader) ReadDouble() (v float64, err error)

ReadDouble ...

func (*BufferReader) ReadFieldBegin added in v0.1.1

func (r *BufferReader) ReadFieldBegin() (typeID TType, id int16, err error)

ReadFieldBegin ...

func (*BufferReader) ReadI16 added in v0.1.1

func (r *BufferReader) ReadI16() (v int16, err error)

ReadI16 ...

func (*BufferReader) ReadI32 added in v0.1.1

func (r *BufferReader) ReadI32() (v int32, err error)

ReadI32 ...

func (*BufferReader) ReadI64 added in v0.1.1

func (r *BufferReader) ReadI64() (v int64, err error)

ReadI64 ...

func (*BufferReader) ReadListBegin added in v0.1.1

func (r *BufferReader) ReadListBegin() (et TType, size int, err error)

ReadListBegin ...

func (*BufferReader) ReadMapBegin added in v0.1.1

func (r *BufferReader) ReadMapBegin() (kt, vt TType, size int, err error)

ReadMapBegin ...

func (*BufferReader) ReadMessageBegin added in v0.1.1

func (r *BufferReader) ReadMessageBegin() (name string, typeID TMessageType, seq int32, err error)

ReadMessageBegin ...

func (*BufferReader) ReadSetBegin added in v0.1.1

func (r *BufferReader) ReadSetBegin() (et TType, size int, err error)

ReadSetBegin ...

func (*BufferReader) ReadString added in v0.1.1

func (r *BufferReader) ReadString() (s string, err error)

ReadString ...

func (*BufferReader) Readn added in v0.1.1

func (r *BufferReader) Readn() int64

Readn returns total bytes read from underlying reader

func (*BufferReader) Recycle added in v0.1.1

func (r *BufferReader) Recycle()

Recycle ...

func (*BufferReader) Skip added in v0.1.1

func (r *BufferReader) Skip(t TType) error

Skip ...

type BufferWriter added in v0.1.1

type BufferWriter struct {
	// contains filtered or unexported fields
}

func NewBufferWriter added in v0.1.1

func NewBufferWriter(iw bufiox.Writer) *BufferWriter

func (*BufferWriter) Recycle added in v0.1.1

func (w *BufferWriter) Recycle()

func (*BufferWriter) WriteBinary added in v0.1.1

func (w *BufferWriter) WriteBinary(v []byte) error

func (*BufferWriter) WriteBool added in v0.1.1

func (w *BufferWriter) WriteBool(v bool) error

func (*BufferWriter) WriteByte added in v0.1.1

func (w *BufferWriter) WriteByte(v int8) error

func (*BufferWriter) WriteDouble added in v0.1.1

func (w *BufferWriter) WriteDouble(v float64) error

func (*BufferWriter) WriteFieldBegin added in v0.1.1

func (w *BufferWriter) WriteFieldBegin(typeID TType, id int16) error

func (*BufferWriter) WriteFieldStop added in v0.1.1

func (w *BufferWriter) WriteFieldStop() error

func (*BufferWriter) WriteI16 added in v0.1.1

func (w *BufferWriter) WriteI16(v int16) error

func (*BufferWriter) WriteI32 added in v0.1.1

func (w *BufferWriter) WriteI32(v int32) error

func (*BufferWriter) WriteI64 added in v0.1.1

func (w *BufferWriter) WriteI64(v int64) error

func (*BufferWriter) WriteListBegin added in v0.1.1

func (w *BufferWriter) WriteListBegin(et TType, size int) error

func (*BufferWriter) WriteMapBegin added in v0.1.1

func (w *BufferWriter) WriteMapBegin(kt, vt TType, size int) error

func (*BufferWriter) WriteMessageBegin added in v0.1.1

func (w *BufferWriter) WriteMessageBegin(name string, typeID TMessageType, seq int32) error

func (*BufferWriter) WriteSetBegin added in v0.1.1

func (w *BufferWriter) WriteSetBegin(et TType, size int) error

func (*BufferWriter) WriteString added in v0.1.1

func (w *BufferWriter) WriteString(v string) error

type FastCodec

type FastCodec interface {
	BLength() int
	FastWriteNocopy(buf []byte, bw NocopyWriter) int
	FastRead(buf []byte) (int, error)
}

FastCodec represents the interface of thrift fastcodec generated structs

type NocopyWriter

type NocopyWriter interface {
	WriteDirect(b []byte, remainCap int) error
}

BinaryWriter represents the method used in thrift encoding for nocopy writes It supports netpoll nocopy feature, see: https://github.com/cloudwego/netpoll/blob/develop/nocopy.go

type ProtocolException

type ProtocolException struct {
	ApplicationException // same implementation ...
	// contains filtered or unexported fields
}

ProtocolException is for replacing apache.ProtocolException it implements ThriftFastCodec interface.

func NewProtocolException

func NewProtocolException(t int32, m string) *ProtocolException

NewTransportExceptionWithType

func NewProtocolExceptionWithErr

func NewProtocolExceptionWithErr(err error) *ProtocolException

NewProtocolException ...

func (*ProtocolException) Is

func (e *ProtocolException) Is(err error) bool

Is ... for errors pkg

func (*ProtocolException) Unwrap

func (e *ProtocolException) Unwrap() error

Unwrap ... for errors pkg

type SkipDecoder

type SkipDecoder struct {
	// contains filtered or unexported fields
}

SkipDecoder scans the underlying io.Reader and returns the bytes of a type

func NewSkipDecoder

func NewSkipDecoder(r bufiox.Reader) *SkipDecoder

NewSkipDecoder ... call Release if no longer use

func (*SkipDecoder) Next

func (p *SkipDecoder) Next(t TType) (buf []byte, err error)

Next skips a specific type and returns its bytes. Callers cannot use the returned data after calling Release.

func (*SkipDecoder) Release

func (p *SkipDecoder) Release()

Release releases the peekAck decoder, callers cannot use the returned data of Next after calling Release.

type TMessageType

type TMessageType = int32 // use alias for better flexibility of interfaces

TMessageType represents message type constants in the Thrift protocol. originally from github.com/apache/thrift

const (
	INVALID_TMESSAGE_TYPE TMessageType = 0
	CALL                  TMessageType = 1
	REPLY                 TMessageType = 2
	EXCEPTION             TMessageType = 3
	ONEWAY                TMessageType = 4
)

type TType

type TType = int8 // use alias for better flexibility of interfaces

TType represents field type constants in the Thrift protocol originally from github.com/apache/thrift

const (
	STOP   TType = 0
	VOID   TType = 1
	BOOL   TType = 2
	BYTE   TType = 3
	I08    TType = 3
	DOUBLE TType = 4
	I16    TType = 6
	I32    TType = 8
	I64    TType = 10
	STRING TType = 11
	UTF7   TType = 11
	STRUCT TType = 12
	MAP    TType = 13
	SET    TType = 14
	LIST   TType = 15
	UTF8   TType = 16
	UTF16  TType = 17
)

type TransportException

type TransportException struct {
	ApplicationException // same implementation ...
}

TransportException is for replacing apache.TransportException it implements ThriftFastCodec interface.

func NewTransportException

func NewTransportException(t int32, m string) *TransportException

NewTransportException ...

Directories

Path Synopsis
Package apache contains code for working with apache thrift indirectly
Package apache contains code for working with apache thrift indirectly
Code generated by thriftgo (0.3.15) (fastgo).
Code generated by thriftgo (0.3.15) (fastgo).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL