codec

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 17 Imported by: 7

Documentation

Index

Constants

View Source
const (
	Size32 = 4
	Size16 = 2
)

The byte count of 32 and 16 integer values.

View Source
const (
	// ThriftV1Magic is the magic code for thrift.VERSION_1
	ThriftV1Magic = 0x80010000
	// ProtobufV1Magic is the magic code for kitex protobuf
	ProtobufV1Magic = 0x90010000

	// MagicMask is bit mask for checking version.
	MagicMask = 0xffff0000
)
View Source
const (
	// Header Magics
	// 0 and 16th bits must be 0 to differentiate from framed & unframed
	TTHeaderMagic     uint32 = 0x10000000
	MeshHeaderMagic   uint32 = 0xFFAF0000
	MeshHeaderLenMask uint32 = 0x0000FFFF

	// HeaderMask        uint32 = 0xFFFF0000
	FlagsMask     uint32 = 0x0000FFFF
	MethodMask    uint32 = 0x41000000 // method first byte [A-Za-z_]
	MaxFrameSize  uint32 = 0x3FFFFFFF
	MaxHeaderSize uint32 = 65536
)

Header keys

View Source
const (
	HeaderFlagsKey              string      = "HeaderFlags"
	HeaderFlagSupportOutOfOrder HeaderFlags = 0x01
	HeaderFlagDuplexReverse     HeaderFlags = 0x08
	HeaderFlagSASL              HeaderFlags = 0x10
)
View Source
const (
	// FrontMask is used in protocol sniffing.
	FrontMask = 0x0000ffff
)
View Source
const (
	TTHeaderMetaSize = 14
)

Variables

This section is empty.

Functions

func Bytes2Uint16

func Bytes2Uint16(bytes []byte, off int) (uint16, error)

Bytes2Uint16 ...

func Bytes2Uint16NoCheck

func Bytes2Uint16NoCheck(bytes []byte) uint16

Bytes2Uint16NoCheck ...

func Bytes2Uint32

func Bytes2Uint32(bytes []byte) (uint32, error)

Bytes2Uint32 ...

func Bytes2Uint32NoCheck

func Bytes2Uint32NoCheck(bytes []byte) uint32

Bytes2Uint32NoCheck ...

func Bytes2Uint8

func Bytes2Uint8(bytes []byte, off int) (uint8, error)

Bytes2Uint8 ...

func IsTTHeader

func IsTTHeader(flagBuf []byte) bool

*

  • +------------------------------------------------------------+
  • | 4Byte | 2Byte |
  • +------------------------------------------------------------+
  • | Length | HEADER MAGIC |
  • +------------------------------------------------------------+

func NewDataIfNeeded

func NewDataIfNeeded(method string, message remote.Message) error

NewDataIfNeeded is used to create the data if not exist.

func NewDefaultCodec

func NewDefaultCodec() remote.Codec

NewDefaultCodec creates the default protocol sniffing codec supporting thrift and protobuf.

func NewDefaultCodecWithSizeLimit added in v0.2.0

func NewDefaultCodecWithSizeLimit(maxSize int) remote.Codec

NewDefaultCodecWithSizeLimit creates the default protocol sniffing codec supporting thrift and protobuf but with size limit. maxSize is in bytes

func PeekUint32

func PeekUint32(in remote.ByteBuffer) (uint32, error)

PeekUint32 ...

func ReadString

func ReadString(in remote.ByteBuffer) (string, int, error)

ReadString ...

func ReadString2BLen

func ReadString2BLen(bytes []byte, off int) (string, int, error)

ReadString2BLen ...

func ReadUint16

func ReadUint16(in remote.ByteBuffer) (uint16, error)

ReadUint16 ...

func ReadUint32

func ReadUint32(in remote.ByteBuffer) (uint32, error)

ReadUint32 ...

func SetOrCheckMethodName

func SetOrCheckMethodName(methodName string, message remote.Message) error

SetOrCheckMethodName is used to set method name to invocation.

func SetOrCheckSeqID

func SetOrCheckSeqID(seqID int32, message remote.Message) error

SetOrCheckSeqID is used to check the sequence ID.

func UpdateMsgType

func UpdateMsgType(msgType uint32, message remote.Message) error

UpdateMsgType updates msg type.

func WriteByte

func WriteByte(val byte, out remote.ByteBuffer) error

WriteByte ...

func WriteString

func WriteString(val string, out remote.ByteBuffer) (int, error)

WriteString ...

func WriteString2BLen

func WriteString2BLen(val string, out remote.ByteBuffer) (int, error)

WriteString2BLen ...

func WriteUint16

func WriteUint16(val uint16, out remote.ByteBuffer) error

WriteUint16 ...

func WriteUint32

func WriteUint32(val uint32, out remote.ByteBuffer) error

WriteUint32 ...

Types

type HeaderFlags

type HeaderFlags uint16

type InfoIDType

type InfoIDType uint8 // uint8
const (
	InfoIDPadding     InfoIDType = 0
	InfoIDKeyValue    InfoIDType = 0x01
	InfoIDIntKeyValue InfoIDType = 0x10
	InfoIDACLToken    InfoIDType = 0x11
)

type ProtocolID

type ProtocolID uint8

ProtocolID is the wrapped protocol id used in THeader.

const (
	ProtocolIDThriftBinary    ProtocolID = 0x00
	ProtocolIDThriftCompact   ProtocolID = 0x02 // Kitex not support
	ProtocolIDThriftCompactV2 ProtocolID = 0x03 // Kitex not support
	ProtocolIDKitexProtobuf   ProtocolID = 0x04
	ProtocolIDDefault                    = ProtocolIDThriftBinary
)

Supported ProtocolID values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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