Documentation ¶
Index ¶
- Constants
- type Matcher
- type MessageAckCommand
- type MessageCommand
- type Proto
- func (proto *Proto) Decode(ctx context.Context, data api.IoBuffer) (interface{}, error)
- func (proto *Proto) EnableWorkerPool() bool
- func (proto *Proto) Encode(ctx context.Context, model interface{}) (api.IoBuffer, error)
- func (proto *Proto) GenerateRequestID(streamID *uint64) uint64
- func (proto *Proto) GoAway(ctx context.Context) api.XFrame
- func (proto *Proto) Hijack(context context.Context, request api.XFrame, statusCode uint32) api.XRespFrame
- func (proto *Proto) Mapping(httpStatusCode uint32) uint32
- func (proto *Proto) Name() api.ProtocolName
- func (proto *Proto) PoolMode() api.PoolMode
- func (proto *Proto) Reply(context context.Context, request api.XFrame) api.XRespFrame
- func (proto *Proto) Trigger(context context.Context, requestId uint64) api.XFrame
- type Request
- func (r *Request) GetData() api.IoBuffer
- func (r *Request) GetHeader() api.HeaderMap
- func (r *Request) GetRequestId() uint64
- func (r *Request) GetStreamType() api.StreamType
- func (r *Request) GetTimeout() int32
- func (r *Request) IsGoAwayFrame() bool
- func (r *Request) IsHeartbeatFrame() bool
- func (r *Request) SetData(data api.IoBuffer)
- func (r *Request) SetRequestId(id uint64)
- type Response
- type StatusMapping
Constants ¶
View Source
const ( ProtocolName api.ProtocolName = "x_example" // protocol Magic byte = 'x' //magic MagicIdx = 0 //magicIndex DirRequest byte = 0 // dir DirResponse byte = 1 // dir TypeHeartbeat byte = 0 // cmd code TypeMessage byte = 1 TypeGoAway byte = 2 ResponseStatusSuccess uint16 = 0 // 0x00 response status ResponseStatusError uint16 = 1 // 0x01 RequestHeaderLen int = 11 // protocol header fields length ResponseHeaderLen int = 13 MinimalDecodeLen int = RequestHeaderLen // minimal length for decoding RequestIdIndex = 3 RequestPayloadIndex = 7 ResponsePayloadIndex = 9 TypeIndex = 1 DirIndex = 2 RequestIdEnd = 6 )
protocol constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher struct{}
func (*Matcher) ExampleMatcher ¶
func (exampleMatcher *Matcher) ExampleMatcher(data []byte) api.MatchResult
predicate codec header len and compare magic number
type MessageAckCommand ¶
type MessageAckCommand struct { Response // TODO: pb deserialize target, extract from Payload Message interface{} }
type MessageCommand ¶
type MessageCommand struct { Request // TODO: pb deserialize target, extract from Payload Message interface{} }
type Proto ¶
type Proto struct{}
func (*Proto) EnableWorkerPool ¶
func (*Proto) GenerateRequestID ¶
func (*Proto) Hijack ¶
func (proto *Proto) Hijack(context context.Context, request api.XFrame, statusCode uint32) api.XRespFrame
Hijacker
func (*Proto) Name ¶
func (proto *Proto) Name() api.ProtocolName
type Request ¶
type Request struct { Type byte RequestId uint32 PayloadLen uint32 Payload api.IoBuffer header.CommonHeader }
func NewRpcRequest ¶
func NewRpcRequest(headers header.CommonHeader, data api.IoBuffer) *Request
NewRpcRequest is a utility function which build rpc Request object of codec protocol.
func (*Request) GetRequestId ¶
func (*Request) GetStreamType ¶
func (r *Request) GetStreamType() api.StreamType
func (*Request) GetTimeout ¶
func (*Request) IsGoAwayFrame ¶ added in v0.27.0
func (*Request) IsHeartbeatFrame ¶
func (*Request) SetRequestId ¶
type Response ¶
func NewRpcResponse ¶
func NewRpcResponse(headers header.CommonHeader, data api.IoBuffer) *Response
NewRpcResponse is a utility function which build rpc Response object of codec protocol.
func (*Response) GetRequestId ¶
func (*Response) GetStatusCode ¶
func (*Response) GetStreamType ¶
func (r *Response) GetStreamType() api.StreamType
func (*Response) SetRequestId ¶
Click to show internal directories.
Click to hide internal directories.