Documentation ¶
Index ¶
- Constants
- Variables
- func FreeMsg(msg *Message)
- func MagicNumber() byte
- func PutData(data *[]byte)
- type CompressType
- type Compressor
- type GzipCompressor
- type Header
- func (h Header) CheckMagicNumber() bool
- func (h Header) CompressType() CompressType
- func (h Header) IsHeartbeat() bool
- func (h Header) IsOneway() bool
- func (h Header) MessageStatusType() MessageStatusType
- func (h Header) MessageType() MessageType
- func (h Header) Seq() uint64
- func (h Header) SerializeType() SerializeType
- func (h *Header) SetCompressType(ct CompressType)
- func (h *Header) SetHeartbeat(hb bool)
- func (h *Header) SetMessageStatusType(mt MessageStatusType)
- func (h *Header) SetMessageType(mt MessageType)
- func (h *Header) SetOneway(oneway bool)
- func (h *Header) SetSeq(seq uint64)
- func (h *Header) SetSerializeType(st SerializeType)
- func (h *Header) SetVersion(v byte)
- func (h Header) Version() byte
- type Message
- type MessageStatusType
- type MessageType
- type RawDataCompressor
- type SerializeType
- type SnappyCompressor
Constants ¶
const (
// ServiceError contains error info of service invocation
ServiceError = "__rpcx_error__"
)
Variables ¶
var ( // ErrMetaKVMissing some keys or values are mssing. ErrMetaKVMissing = errors.New("wrong metadata lines. some keys or values are missing") // ErrMessageTooLong message is too long ErrMessageTooLong = errors.New("message is too long") ErrUnsupportedCompressor = errors.New("unsupported compressor") )
var ( // Compressors are compressors supported by rpcx. You can add customized compressor in Compressors. Compressors = map[CompressType]Compressor{ None: &RawDataCompressor{}, Gzip: &GzipCompressor{}, } )
var MaxMessageLength = 0
MaxMessageLength is the max length of a message. Default is 0 that means does not limit length of messages. It is used to validate when read messages from io.Reader.
Functions ¶
func MagicNumber ¶
func MagicNumber() byte
Types ¶
type CompressType ¶
type CompressType byte
CompressType defines decompression type.
const ( // None does not compress. None CompressType = iota // Gzip uses gzip compression. Gzip )
type Compressor ¶
Compressor defines a common compression interface.
type Header ¶
type Header [12]byte
Header is the first part of Message and has fixed size. Format:
func (Header) CheckMagicNumber ¶
CheckMagicNumber checks whether header starts rpcx magic number.
func (Header) CompressType ¶
func (h Header) CompressType() CompressType
CompressType returns compression type of messages.
func (Header) IsHeartbeat ¶
IsHeartbeat returns whether the message is heartbeat message.
func (Header) IsOneway ¶
IsOneway returns whether the message is one-way message. If true, server won't send responses.
func (Header) MessageStatusType ¶
func (h Header) MessageStatusType() MessageStatusType
MessageStatusType returns the message status type.
func (Header) MessageType ¶
func (h Header) MessageType() MessageType
MessageType returns the message type.
func (Header) SerializeType ¶
func (h Header) SerializeType() SerializeType
SerializeType returns serialization type of payload.
func (*Header) SetCompressType ¶
func (h *Header) SetCompressType(ct CompressType)
SetCompressType sets the compression type.
func (*Header) SetHeartbeat ¶
SetHeartbeat sets the heartbeat flag.
func (*Header) SetMessageStatusType ¶
func (h *Header) SetMessageStatusType(mt MessageStatusType)
SetMessageStatusType sets message status type.
func (*Header) SetMessageType ¶
func (h *Header) SetMessageType(mt MessageType)
SetMessageType sets message type.
func (*Header) SetSerializeType ¶
func (h *Header) SetSerializeType(st SerializeType)
SetSerializeType sets the serialization type.
func (*Header) SetVersion ¶
SetVersion sets version for this header.
type Message ¶
type Message struct { *Header ServicePath string ServiceMethod string Metadata map[string]string Payload []byte // contains filtered or unexported fields }
Message is the generic type of Request and Response.
func (Message) EncodeSlicePointer ¶
EncodeSlicePointer encodes messages as a byte slice poiter we we can use pool to improve.
type MessageStatusType ¶
type MessageStatusType byte
MessageStatusType is status of messages.
const ( // Normal is normal requests and responses. Normal MessageStatusType = iota // Error indicates some errors occur. Error )
type MessageType ¶
type MessageType byte
MessageType is message type of requests and resposnes.
const ( // Request is message type of request Request MessageType = iota // Response is message type of response Response )
type RawDataCompressor ¶
type RawDataCompressor struct { }
type SerializeType ¶
type SerializeType byte
SerializeType defines serialization type of payload.
const ( // SerializeNone uses raw []byte and don't serialize/deserialize SerializeNone SerializeType = iota // JSON for payload. JSON // ProtoBuffer for payload. ProtoBuffer // MsgPack for payload MsgPack // Thrift // Thrift for payload Thrift )
type SnappyCompressor ¶
type SnappyCompressor struct { }
SnappyCompressor implements snappy compressor