example

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolName types.ProtocolName = "x_example" // protocol

	Magic       byte = 'x' //magic
	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
)

protocol constants

Variables

This section is empty.

Functions

func NewCodec

func NewCodec() types.Protocol

Types

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 Request

type Request struct {
	Type       byte
	RequestId  uint32
	PayloadLen uint32
	Payload    []byte
	Content    types.IoBuffer
}

func (*Request) GetRequestId

func (r *Request) GetRequestId() uint64

func (*Request) GetStreamType

func (r *Request) GetStreamType() xprotocol.StreamType

func (*Request) SetRequestId

func (r *Request) SetRequestId(id uint64)

type Response

type Response struct {
	Request
	Status uint16
}

func (*Response) GetRequestId

func (r *Response) GetRequestId() uint64

func (*Response) GetStreamType

func (r *Response) GetStreamType() xprotocol.StreamType

func (*Response) SetRequestId

func (r *Response) SetRequestId(id uint64)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL