Documentation
¶
Overview ¶
Package protocol is motan2 protocol codec implements.
Index ¶
- Constants
- func ConvertToRequest(request *Message, serialize motan.Serialization) (motan.Request, error)
- func ConvertToResponse(response *Message, serialize motan.Serialization) (motan.Response, error)
- func DecodeGzip(data []byte) ([]byte, error)
- func DecodeGzipBody(body []byte) []byte
- func EncodeGzip(data []byte) ([]byte, error)
- func ExceptionToJSON(e *motan.Exception) string
- type Header
- func (h *Header) GetSerialize() int
- func (h *Header) GetStatus() int
- func (h *Header) GetVersion() int
- func (h *Header) IsGzip() bool
- func (h *Header) IsHeartbeat() bool
- func (h *Header) IsOneWay() bool
- func (h *Header) IsProxy() bool
- func (h *Header) SetGzip(isgzip bool)
- func (h *Header) SetHeartbeat(isHeartbeat bool)
- func (h *Header) SetOneWay(isOneWay bool)
- func (h *Header) SetProxy(isProxy bool)
- func (h *Header) SetRequest(isRequest bool)
- func (h *Header) SetSerialize(serialize int) error
- func (h *Header) SetStatus(status int) error
- func (h *Header) SetVersion(version int) error
- type Message
- func BuildExceptionResponse(requestID uint64, errmsg string) *Message
- func BuildHeartbeat(requestID uint64, msgType int) *Message
- func ConvertToReqMessage(request motan.Request, serialize motan.Serialization) (*Message, error)
- func ConvertToResMessage(response motan.Response, serialize motan.Serialization) (*Message, error)
- func Decode(buf *bufio.Reader) (msg *Message, err error)
Constants ¶
View Source
const ( Req = iota Res )
message type
View Source
const ( MotanMagic = 0xf1f1 HeaderLength = 13 )
message magic
View Source
const ( MPath = "M_p" MMethod = "M_m" MExceptionn = "M_e" MProcessTime = "M_pt" MMethodDesc = "M_md" MGroup = "M_g" MProxyProtocol = "M_pp" MVersion = "M_v" MModule = "M_mdu" MSource = "M_s" )
View Source
const ( Hessian = iota GrpcPb JSON Msgpack Hprose Pb Simple GrpcJSON )
serialize
View Source
const ( Normal = iota Exception )
message status
Variables ¶
This section is empty.
Functions ¶
func ConvertToRequest ¶
ConvertToRequest convert motan2 protocol request message to motan Request
func ConvertToResponse ¶
ConvertToResponse convert protocol response to motan Response
func DecodeGzipBody ¶
func ExceptionToJSON ¶
Types ¶
type Header ¶
type Header struct { Magic uint16 MsgType uint8 VersionStatus uint8 Serialize uint8 RequestID uint64 }
func BuildHeader ¶
BuildHeader build header with common set
func BuildRequestHeader ¶
BuildRequestHeader build a proxy request header
func BuildResponseHeader ¶
func (*Header) GetSerialize ¶
func (*Header) GetVersion ¶
func (*Header) IsHeartbeat ¶
func (*Header) SetHeartbeat ¶
func (*Header) SetRequest ¶
func (*Header) SetSerialize ¶
func (*Header) SetVersion ¶
type Message ¶
func BuildExceptionResponse ¶
func BuildHeartbeat ¶
func ConvertToReqMessage ¶
ConvertToReqMessage convert motan Request to protocol request
func ConvertToResMessage ¶
ConvertToResMessage convert motan Response to protocol response
Click to show internal directories.
Click to hide internal directories.