Documentation
¶
Index ¶
Constants ¶
View Source
const ( Proto = iota Thrift Arvo )
协议protocol打包类型.
View Source
const ( GeneralMsg = 0x0 HeartMsg = 0x1 )
消息类型.
View Source
const ( SendAndRecv = iota SendOnly LongConn StreamTrans )
请求类型.
View Source
const DefaultBufferLength = 1024
View Source
const FrameHeaderLen = 15
View Source
const Magic = 0x12
View Source
const MaxPayloadLength = 4 * 1024 * 1024
View Source
const (
NoneCompress = iota
)
压缩类型.
View Source
const Version = 0
Variables ¶
View Source
var ( ErrorFrameHeaderRead = errors.New("frame header read error") ErrorMagicNumber = errors.New("magic number error ") ErrorRPCVersion = errors.New("version error") ErrorPayloadOutLength = errors.New("payload beyond max length") ErrorPayloadRead = errors.New("read payload error") )
View Source
var DefaultCodec = NewDefaultCodec()
View Source
var MsgBuilder = &messageBuilder{
msg: &msg{},
}
View Source
var NewDefaultCodec = func() Codec {
return &codec{}
}
Functions ¶
func RegisterCodeC ¶
func StrToCompressType ¶
strToCompressType 解析string类型为uint8类型的compressType帧头.
func StrToPackageType ¶
StrToPackageType string类型转到uint8放到帧头压缩.
Types ¶
type FrameHeader ¶
type FrameHeader struct {
// Magic 魔数.
Magic uint8
// Version 版本号.
Version uint8
// MsgType 消息类型.
MsgType uint8
// ReqType 请求类型.
ReqType uint8
// CompressType 压缩类型.
CompressType uint8
// StreamID 暂时没用,后续扩展.
StreamID uint8
// PackageType 用于包头压缩类型
PackageType uint8
// Length 帧长度.
Length uint32
// Reserved 保留位.
Reserved uint32
}
FrameHeader 帧头.
type FramerBuilder ¶
var DefaultFramerBuilder FramerBuilder
type MessageBuilder ¶
type MessageBuilder interface {
WithSerializerType(string) MessageBuilder
WithCompressType(string) MessageBuilder
WithPackageType(string) MessageBuilder
WithMsgType(uint8) MessageBuilder
WithReqType(uint8) MessageBuilder
WithClientServiceName(string) MessageBuilder
WithServerServiceName(string) MessageBuilder
WithRPCMethodName(string) MessageBuilder
WithRequestID(id uint8) MessageBuilder
WithRetCode(uint32) MessageBuilder
WithRetMsg(string) MessageBuilder
Build() Msg
}
func NewMsgBuilder ¶
func NewMsgBuilder() MessageBuilder
type Msg ¶
type Msg interface {
SerializerType() string
CompressType() uint8
PackageType() uint8
MsgType() uint8
ReqType() uint8
ClientServiceName() string
ServerServiceName() string
RPCMethodName() string
RequestID() uint8
RetCode() uint32
RetMsg() string
WithSerializerType(string)
WithCompressType(uint8)
WithPackageType(uint8)
WithMsgType(uint8)
WithReqType(uint8)
WithClientServiceName(string)
WithServerServiceName(string)
WithRPCMethodName(string)
WithRequestID(uint8)
WithRetCode(uint32)
WithRetMsg(string)
}
TODO msg
Click to show internal directories.
Click to hide internal directories.