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 TTHeaderMagic = ttheader.TTHeaderMagic MeshHeaderMagic uint32 = 0xFFAF0000 MeshHeaderLenMask uint32 = 0x0000FFFF // HeaderMask = 0xFFFF0000 FlagsMask = ttheader.FlagsMask MethodMask = ttheader.MethodMask MaxFrameSize = ttheader.MaxFrameSize MaxHeaderSize = ttheader.MaxHeaderSize )
Header keys
const ( HeaderFlagsKey string = "HeaderFlags" HeaderFlagSupportOutOfOrder = ttheader.HeaderFlagSupportOutOfOrder HeaderFlagDuplexReverse = ttheader.HeaderFlagDuplexReverse HeaderFlagSASL = ttheader.HeaderFlagSASL )
const ( ProtocolIDThriftBinary = ttheader.ProtocolIDThriftBinary ProtocolIDThriftCompact = ttheader.ProtocolIDThriftCompact ProtocolIDThriftCompactV2 = ttheader.ProtocolIDThriftCompactV2 ProtocolIDKitexProtobuf = ttheader.ProtocolIDKitexProtobuf ProtocolIDDefault = ttheader.ProtocolIDDefault )
const ( InfoIDPadding = ttheader.InfoIDPadding InfoIDKeyValue = ttheader.InfoIDKeyValue InfoIDIntKeyValue = ttheader.InfoIDIntKeyValue InfoIDACLToken = ttheader.InfoIDACLToken )
const (
// FrontMask is used in protocol sniffing.
FrontMask = 0x0000ffff
)
const (
PayloadValidatorPrefix = "PV_"
)
const (
TTHeaderMetaSize = ttheader.TTHeaderMetaSize
)
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 = ttheader.HeaderFlags
type InfoIDType ¶
type InfoIDType = ttheader.InfoIDType
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 = ttheader.ProtocolID
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. |