Documentation ¶
Index ¶
- Constants
- func Bytes2Uint16(bytes []byte, off int) (uint16, error)
- func Bytes2Uint16NoCheck(bytes []byte) uint16
- func Bytes2Uint32(bytes []byte) (uint32, error)
- func Bytes2Uint32NoCheck(bytes []byte) uint32
- func Bytes2Uint8(bytes []byte, off int) (uint8, error)
- func IsTTHeader(flagBuf []byte) bool
- func NewDataIfNeeded(method string, message remote.Message) error
- func NewDefaultCodec() remote.Codec
- func NewDefaultCodecWithConfig(cfg CodecConfig) remote.Codec
- func NewDefaultCodecWithSizeLimit(maxSize int) remote.Codec
- func PeekUint32(in remote.ByteBuffer) (uint32, error)
- func ReadString(in remote.ByteBuffer) (string, int, error)
- func ReadString2BLen(bytes []byte, off int) (string, int, error)
- func ReadUint16(in remote.ByteBuffer) (uint16, error)
- func ReadUint32(in remote.ByteBuffer) (uint32, error)
- func SetOrCheckMethodName(methodName string, message remote.Message) error
- func SetOrCheckSeqID(seqID int32, message remote.Message) error
- func UpdateMsgType(msgType uint32, message remote.Message) error
- func WriteByte(val byte, out remote.ByteBuffer) error
- func WriteString(val string, out remote.ByteBuffer) (int, error)
- func WriteString2BLen(val string, out remote.ByteBuffer) (int, error)
- func WriteUint16(val uint16, out remote.ByteBuffer) error
- func WriteUint32(val uint32, out remote.ByteBuffer) error
- type CodecConfig
- type HeaderFlags
- type InfoIDType
- type PayloadValidator
- type ProtocolID
Constants ¶
const ( Size32 = 4 Size16 = 2 )
The byte count of 32 and 16 integer values.
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 )
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
const ( HeaderFlagsKey string = "HeaderFlags" HeaderFlagSupportOutOfOrder HeaderFlags = 0x01 HeaderFlagDuplexReverse HeaderFlags = 0x08 HeaderFlagSASL HeaderFlags = 0x10 )
const (
// FrontMask is used in protocol sniffing.
FrontMask = 0x0000ffff
)
const (
PayloadValidatorPrefix = "PV_"
)
const (
TTHeaderMetaSize = 14
)
Variables ¶
This section is empty.
Functions ¶
func IsTTHeader ¶
*
- +------------------------------------------------------------+
- | 4Byte | 2Byte |
- +------------------------------------------------------------+
- | Length | HEADER MAGIC |
- +------------------------------------------------------------+
func NewDataIfNeeded ¶
NewDataIfNeeded is used to create the data if not exist.
func NewDefaultCodec ¶
NewDefaultCodec creates the default protocol sniffing codec supporting thrift and protobuf.
func NewDefaultCodecWithConfig ¶ added in v0.11.0
func NewDefaultCodecWithConfig(cfg CodecConfig) remote.Codec
NewDefaultCodecWithConfig creates the default protocol sniffing codec supporting thrift and protobuf with the input config.
func NewDefaultCodecWithSizeLimit ¶ added in v0.2.0
NewDefaultCodecWithSizeLimit creates the default protocol sniffing codec supporting thrift and protobuf but with size limit. maxSize is in bytes
func ReadString2BLen ¶
ReadString2BLen ...
func SetOrCheckMethodName ¶
SetOrCheckMethodName is used to set method name to invocation.
func SetOrCheckSeqID ¶
SetOrCheckSeqID is used to check the sequence ID.
func UpdateMsgType ¶
UpdateMsgType updates msg type.
func WriteString2BLen ¶
func WriteString2BLen(val string, out remote.ByteBuffer) (int, error)
WriteString2BLen ...
Types ¶
type CodecConfig ¶ added in v0.11.0
type CodecConfig struct { // maxSize limits the max size of the payload MaxSize int // If crc32Check is true, the codec will validate the payload using crc32c. // Only effective when transport is TTHeader. // Payload is all the data after TTHeader. CRC32Check bool // PayloadValidator is used to validate payload with customized checksum logic. // It prepares a value based on payload in sender-side and validates the value in receiver-side. // It can only be used when ttheader is enabled. PayloadValidator PayloadValidator }
CodecConfig is the config of defaultCodec
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 PayloadValidator ¶ added in v0.11.0
type PayloadValidator interface { // Key returns a key for your validator, which will be the key in ttheader Key(ctx context.Context) string // Generate generates the checksum of the payload. // The value will not be set to the request header if "need" is false. // DO NOT modify the input payload since it might be obtained by nocopy API from the underlying buffer. Generate(ctx context.Context, outboundPayload []byte) (need bool, checksum string, err error) // Validate validates the input payload with the attached checksum. // Return pass if validation succeed, or return error. // DO NOT modify the input payload since it might be obtained by nocopy API from the underlying buffer. Validate(ctx context.Context, expectedValue string, inboundPayload []byte) (pass bool, err error) }
PayloadValidator is the interface for validating the payload of RPC requests, which allows customized Checksum function.
func NewCRC32PayloadValidator ¶ added in v0.11.0
func NewCRC32PayloadValidator() PayloadValidator
NewCRC32PayloadValidator returns a new crcPayloadValidator
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
encoding
Package encoding defines the interface for the compressor and codec, and functions to register and retrieve compressors and codecs.
|
Package encoding defines the interface for the compressor and codec, and functions to register and retrieve compressors and codecs. |
encoding/gzip
Package gzip implements and registers the gzip compressor during the initialization.
|
Package gzip implements and registers the gzip compressor during the initialization. |