xr

package
v0.0.0-...-f847aad Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseStatusSuccess uint32 = 0 // 0 response status
	RequestHeaderLen      int    = 8 // fix 8 byte header length
)

Variables

View Source
var Xr api.ProtocolName = "xr" // protocol

Functions

This section is empty.

Types

type KeyValueEntry

type KeyValueEntry struct {
	XMLName xml.Name
	Value   string `xml:",chardata"`
}

type Matcher

type Matcher struct{}

func (*Matcher) XrProtocolMatcher

func (m *Matcher) XrProtocolMatcher(data []byte) api.MatchResult

type Request

type Request struct {
	common.Header              // request key value pair
	RequestId     string       // request id (biz id)
	SteamId       interface{}  // sidecar request id (replaced by sidecar, uint64 or nil)
	Timeout       uint32       // request timeout
	Content       api.IoBuffer // it refers to the service parameters of a packet
	Data          api.IoBuffer // full package bytes
	Changed       bool         // indicates whether the packet payload is modified
}

func NewRpcRequest

func NewRpcRequest(headers *common.Header, data api.IoBuffer) *Request

NewRpcRequest is a utility function which build rpc Request object of xr protocol.

func (*Request) GetData

func (r *Request) GetData() api.IoBuffer

func (*Request) GetHeader

func (r *Request) GetHeader() api.HeaderMap

func (*Request) GetRequestId

func (r *Request) GetRequestId() uint64

func (*Request) GetStreamType

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

func (*Request) GetTimeout

func (r *Request) GetTimeout() int32

func (*Request) IsHeartbeatFrame

func (r *Request) IsHeartbeatFrame() bool

func (*Request) SetData

func (r *Request) SetData(data api.IoBuffer)

func (*Request) SetRequestId

func (r *Request) SetRequestId(id uint64)

type Response

type Response struct {
	common.Header              // response key value pair
	RequestId     string       // response id
	SteamId       interface{}  // sidecar request id (replaced by sidecar id)
	Status        uint32       // response status
	Data          api.IoBuffer // full package bytes
	Content       api.IoBuffer // it refers to the service parameters of a packet
	Changed       bool         // indicates whether the packet payload is modified
}

func NewRpcResponse

func NewRpcResponse(headers *common.Header, data api.IoBuffer) *Response

NewRpcResponse is a utility function which build rpc Response object of xr protocol.

func (*Response) GetData

func (r *Response) GetData() api.IoBuffer

func (*Response) GetHeader

func (r *Response) GetHeader() api.HeaderMap

func (*Response) GetRequestId

func (r *Response) GetRequestId() uint64

func (*Response) GetStatusCode

func (r *Response) GetStatusCode() uint32

func (*Response) GetStreamType

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

func (*Response) GetTimeout

func (r *Response) GetTimeout() int32

func (*Response) IsHeartbeatFrame

func (r *Response) IsHeartbeatFrame() bool

func (*Response) SetData

func (r *Response) SetData(data api.IoBuffer)

func (*Response) SetRequestId

func (r *Response) SetRequestId(id uint64)

type StatusMapping

type StatusMapping struct{}

func (*StatusMapping) MappingHeaderStatusCode

func (m *StatusMapping) MappingHeaderStatusCode(ctx context.Context, headers api.HeaderMap) (int, error)

type XmlHeader

type XmlHeader map[string]string

XmlHeader xml key value pair. Protocol-specific, depending on traditional protocol data structures

func (XmlHeader) MarshalXML

func (m XmlHeader) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*XmlHeader) UnmarshalXML

func (m *XmlHeader) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type XrProtocol

type XrProtocol struct {
	// contains filtered or unexported fields
}

func (*XrProtocol) Decode

func (proto *XrProtocol) Decode(ctx context.Context, buf api.IoBuffer) (interface{}, error)

func (*XrProtocol) EnableWorkerPool

func (proto *XrProtocol) EnableWorkerPool() bool

func (*XrProtocol) Encode

func (proto *XrProtocol) Encode(ctx context.Context, model interface{}) (api.IoBuffer, error)

func (*XrProtocol) GenerateRequestID

func (proto *XrProtocol) GenerateRequestID(streamID *uint64) uint64

func (*XrProtocol) Hijack

func (proto *XrProtocol) Hijack(context context.Context, request api.XFrame, statusCode uint32) api.XRespFrame

Hijack hijack request, maybe timeout

func (*XrProtocol) Mapping

func (proto *XrProtocol) Mapping(httpStatusCode uint32) uint32

func (*XrProtocol) Name

func (proto *XrProtocol) Name() api.ProtocolName

func (*XrProtocol) PoolMode

func (proto *XrProtocol) PoolMode() api.PoolMode

PoolMode returns whether ping-pong or multiplex

func (*XrProtocol) PutStreamId

func (proto *XrProtocol) PutStreamId(ctx context.Context, key string, val uint64) (err error)

PutStreamId put mapping stream id

func (*XrProtocol) RemoveStreamId

func (proto *XrProtocol) RemoveStreamId(ctx context.Context, key string)

func (*XrProtocol) Reply

func (proto *XrProtocol) Reply(context context.Context, request api.XFrame) api.XRespFrame

func (*XrProtocol) StreamId

func (proto *XrProtocol) StreamId(ctx context.Context, key string) (val uint64, found bool)

StreamId query mapping stream id

func (*XrProtocol) Trigger

func (proto *XrProtocol) Trigger(context context.Context, requestId uint64) api.XFrame

Trigger heartbeat detect.

Jump to

Keyboard shortcuts

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