bthrift

package
v0.11.3-genericstream Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 884

README

bthrift

bthrift is no longer used, but the legacy generated code may still rely on it. For newly added code, should use github.com/cloudwego/gopkg/protocol/thrift instead.

We're planning to get rid of github.com/apache/thrift, here are steps we have done:

  1. Removed unnecessary dependencies of apache from kitex
  2. Moved all apache dependencies to bthrift/apache, mainly types, interfaces and consts
    • We may use type alias at the beginning for better compatibility
    • bthrift/apachecalls apache.RegisterXXX in gopkg for step 4
  3. For internal dependencies of apache, use gopkg
  4. For existing framework code working with apache thrift:
    • Use gopkg/protocol/thrift/apache
  5. For Kitex tool:
    • Use gopkg/protocol/thrift for fastcodec
    • replace github.com/apache/thrift with bthrift/apache
      • by using thrift_import_path parameter of thriftgo

The final step we planned to do in kitex version v0.12.0:

  • Add go.mod for bthrift
  • Remove the last github.com/apache/thrift dependencies (Remove the import 'github.com/cloudwego/kitex/pkg/protocol/bthrift' and 'github.com/cloudwego/kitex/pkg/protocol/bthrift/apache')
    • ThriftMessageCodec of pkg/utils
    • MessageReader and MessageWriter interfaces in pkg/remote/codec/thrift
    • BinaryProtocol type in pkg/remote/codec/thrift
    • basic codec tests in pkg/remote/codec/thrift
  • kitex DOESN'T DEPEND bthrift, bthrift will only be dependent in the generated code(if has apache thrift code)

Documentation

Overview

Package bthrift .

Package bthrift is byted thrift

Index

Constants

This section is empty.

Variables

View Source
var (
	// Binary protocol for bthrift.
	Binary binaryProtocol
)

Functions

func SetSpanCache added in v0.10.1

func SetSpanCache(enable bool)

SetSpanCache enable/disable binary protocol bytes/string allocator Deprecated: use github.com/cloudwego/gopkg/protocol/thrift.SetSpanCache

func UnknownFieldsLength added in v0.5.2

func UnknownFieldsLength(fs []UnknownField) (int, error)

UnknownFieldsLength returns the length of fs. Deprecated: use the method under github.com/cloudwego/gopkg/protocol/thrift/unknownfields

func WriteUnknownFields added in v0.5.2

func WriteUnknownFields(buf []byte, fs []UnknownField) (offset int, err error)

WriteUnknownFields writes fs into buf, and return written offset of the buf. Deprecated: use the method under github.com/cloudwego/gopkg/protocol/thrift/unknownfields

Types

type BTProtocol

type BTProtocol interface {
	WriteMessageBegin(buf []byte, name string, typeID thrift.TMessageType, seqid int32) int
	WriteMessageEnd(buf []byte) int
	WriteStructBegin(buf []byte, name string) int
	WriteStructEnd(buf []byte) int
	WriteFieldBegin(buf []byte, name string, typeID thrift.TType, id int16) int
	WriteFieldEnd(buf []byte) int
	WriteFieldStop(buf []byte) int
	WriteMapBegin(buf []byte, keyType, valueType thrift.TType, size int) int
	WriteMapEnd(buf []byte) int
	WriteListBegin(buf []byte, elemType thrift.TType, size int) int
	WriteListEnd(buf []byte) int
	WriteSetBegin(buf []byte, elemType thrift.TType, size int) int
	WriteSetEnd(buf []byte) int
	WriteBool(buf []byte, value bool) int
	WriteByte(buf []byte, value int8) int
	WriteI16(buf []byte, value int16) int
	WriteI32(buf []byte, value int32) int
	WriteI64(buf []byte, value int64) int
	WriteDouble(buf []byte, value float64) int
	WriteString(buf []byte, value string) int
	WriteBinary(buf, value []byte) int
	WriteStringNocopy(buf []byte, binaryWriter BinaryWriter, value string) int
	WriteBinaryNocopy(buf []byte, binaryWriter BinaryWriter, value []byte) int
	MessageBeginLength(name string, typeID thrift.TMessageType, seqid int32) int
	MessageEndLength() int
	StructBeginLength(name string) int
	StructEndLength() int
	FieldBeginLength(name string, typeID thrift.TType, id int16) int
	FieldEndLength() int
	FieldStopLength() int
	MapBeginLength(keyType, valueType thrift.TType, size int) int
	MapEndLength() int
	ListBeginLength(elemType thrift.TType, size int) int
	ListEndLength() int
	SetBeginLength(elemType thrift.TType, size int) int
	SetEndLength() int
	BoolLength(value bool) int
	ByteLength(value int8) int
	I16Length(value int16) int
	I32Length(value int32) int
	I64Length(value int64) int
	DoubleLength(value float64) int
	StringLength(value string) int
	BinaryLength(value []byte) int
	StringLengthNocopy(value string) int
	BinaryLengthNocopy(value []byte) int
	ReadMessageBegin(buf []byte) (name string, typeID thrift.TMessageType, seqid int32, length int, err error)
	ReadMessageEnd(buf []byte) (int, error)
	ReadStructBegin(buf []byte) (name string, length int, err error)
	ReadStructEnd(buf []byte) (int, error)
	ReadFieldBegin(buf []byte) (name string, typeID thrift.TType, id int16, length int, err error)
	ReadFieldEnd(buf []byte) (int, error)
	ReadMapBegin(buf []byte) (keyType, valueType thrift.TType, size, length int, err error)
	ReadMapEnd(buf []byte) (int, error)
	ReadListBegin(buf []byte) (elemType thrift.TType, size, length int, err error)
	ReadListEnd(buf []byte) (int, error)
	ReadSetBegin(buf []byte) (elemType thrift.TType, size, length int, err error)
	ReadSetEnd(buf []byte) (int, error)
	ReadBool(buf []byte) (value bool, length int, err error)
	ReadByte(buf []byte) (value int8, length int, err error)
	ReadI16(buf []byte) (value int16, length int, err error)
	ReadI32(buf []byte) (value int32, length int, err error)
	ReadI64(buf []byte) (value int64, length int, err error)
	ReadDouble(buf []byte) (value float64, length int, err error)
	ReadString(buf []byte) (value string, length int, err error)
	ReadBinary(buf []byte) (value []byte, length int, err error)
	Skip(buf []byte, fieldType thrift.TType) (length int, err error)
}

BTProtocol .

type BinaryWriter

type BinaryWriter = gopkgthrift.NocopyWriter

BinaryWriter . Deprecated: use `github.com/cloudwego/gopkg/protocol/thrift.NocopyWriter`

type UnknownField added in v0.7.1

type UnknownField struct {
	Name    string
	ID      int16
	Type    int
	KeyType int
	ValType int
	Value   interface{}
}

UnknownField is used to describe an unknown field.

func ConvertUnknownFields added in v0.7.1

func ConvertUnknownFields(buf unknown.Fields) (fields []UnknownField, err error)

ConvertUnknownFields converts buf to deserialized unknown fields. Deprecated: use the method under github.com/cloudwego/gopkg/protocol/thrift/unknownfields

func GetUnknownFields added in v0.7.1

func GetUnknownFields(v interface{}) (fields []UnknownField, err error)

GetUnknownFields deserialize unknownfields stored in v to a list of *UnknownFields. Deprecated: use the method under github.com/cloudwego/gopkg/protocol/thrift/unknownfields

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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