Documentation ¶
Index ¶
- Constants
- func DecodeMap(buf []byte) map[string]string
- func EncodeMap(pairs map[string]string) []byte
- func NewWasmRpcProtocol(pw types.WasmPluginWrapper, wrapper *protocolWrapper) *wasmProtocol
- type AbiV2Impl
- func (a *AbiV2Impl) Name() string
- func (a *AbiV2Impl) ProxyDecodeBufferBytes(contextId int32, buf types.IoBuffer) error
- func (a *AbiV2Impl) ProxyEncodeRequestBufferBytes(contextId int32, cmd api.XFrame) error
- func (a *AbiV2Impl) ProxyEncodeResponseBufferBytes(contextId int32, cmd api.XRespFrame) error
- func (a *AbiV2Impl) ProxyHijackBufferBytes(contextId int32, cmd api.XFrame, statusCode uint32) error
- func (a *AbiV2Impl) ProxyKeepAliveBufferBytes(contextId int32, id uint64) error
- func (a *AbiV2Impl) ProxyReplyKeepAliveBufferBytes(contextId int32, cmd api.XFrame) error
- type Context
- func (c *Context) ContextId() int32
- func (c *Context) GetCustomBuffer(bufferType proxywasm.BufferType) common.IoBuffer
- func (c *Context) GetDecodeBuffer() api.IoBuffer
- func (c *Context) GetDecodeCmd() api.XFrame
- func (c *Context) GetEncodeBuffer() api.IoBuffer
- func (c *Context) GetEncodeCmd() api.XFrame
- func (c *Context) SetDecodeBuffer(buf api.IoBuffer)
- func (c *Context) SetDecodeCmd(cmd api.XFrame)
- func (c *Context) SetEncodeBuffer(buf api.IoBuffer)
- func (c *Context) SetEncodeCmd(cmd api.XFrame)
- type ContextCallback
- type ProtocolConfig
- type ProxyProtocolManager
- type ProxyProtocolWrapper
- type Request
- func (r *Request) GetData() types.IoBuffer
- func (r *Request) GetHeader() types.HeaderMap
- func (r *Request) GetId() uint64
- func (r *Request) GetRequestId() uint64
- func (r *Request) GetStreamType() api.StreamType
- func (r *Request) GetTimeout() int32
- func (r *Request) IsHeartbeatFrame() bool
- func (r *Request) SetData(data types.IoBuffer)
- func (r *Request) SetRequestId(id uint64)
- type RequestHeader
- type Response
- func (r *Response) GetData() types.IoBuffer
- func (r *Response) GetHeader() types.HeaderMap
- func (r *Response) GetId() uint64
- func (r *Response) GetRequestId() uint64
- func (r *Response) GetStatusCode() uint32
- func (r *Response) GetStreamType() api.StreamType
- func (r *Response) GetTimeout() int32
- func (r *Response) IsHeartbeatFrame() bool
- func (r *Response) SetData(data types.IoBuffer)
- func (r *Response) SetRequestId(id uint64)
- type ResponseHeader
- type RpcHeader
Constants ¶
View Source
const ( ResponseType = 0 RequestType = 1 RequestOneWayType = 2 HeartBeatFlag byte = 1 << 5 RpcHeaderLength = 16 RpcMagic = 0xAF RpcVersion = 1 RpcRequestFlag byte = 1 << 6 RpcOneWayRequestFlag byte = 1<<6 | 1<<7 RpcResponseFlag byte = 0 RpcIdIndex = 4 RpcTimeout = "timeout" RpcResponseStatus = 0 UnKnownMagicType = "unknown magic type" UnKnownProtocolType = "unknown protocol code type" UnKnownRpcFlagType = "unknown protocol flag type" )
View Source
const ( BufferTypeDecodeData proxywasm.BufferType = 13 BufferTypeEncodeData proxywasm.BufferType = 14 StatusNeedMoreData proxywasm.WasmResult = 99 )
extension for protocol
Variables ¶
This section is empty.
Functions ¶
func EncodeMap ¶
EncodeMap encode map to bytes encoded bytes format: pairs number + all key/value length + all key/value bytes
eg: {"key1": "value1", "hello": "world"} 2(pairs number) + 4(key1 length) + 6(value1 length) => { "key1": "value1" } length
- 5(hello length) + 5(world length) => { "hello": "world" } length
- key1 bytes + nil byte + value1 bytes + nil byte => { "key1": "value1" } bytes
- hello bytes + nil byte + world bytes + nil byte => { "hello": "world" } bytes
func NewWasmRpcProtocol ¶
func NewWasmRpcProtocol(pw types.WasmPluginWrapper, wrapper *protocolWrapper) *wasmProtocol
Types ¶
type AbiV2Impl ¶
type AbiV2Impl struct {
v1.ABIContext
}
easy for extension
func (*AbiV2Impl) ProxyDecodeBufferBytes ¶
func (*AbiV2Impl) ProxyEncodeRequestBufferBytes ¶
func (*AbiV2Impl) ProxyEncodeResponseBufferBytes ¶
func (a *AbiV2Impl) ProxyEncodeResponseBufferBytes(contextId int32, cmd api.XRespFrame) error
func (*AbiV2Impl) ProxyHijackBufferBytes ¶
func (*AbiV2Impl) ProxyKeepAliveBufferBytes ¶
type Context ¶
type Context struct { v1.DefaultImportsHandler // contains filtered or unexported fields }
func (*Context) GetCustomBuffer ¶
func (c *Context) GetCustomBuffer(bufferType proxywasm.BufferType) common.IoBuffer
func (*Context) GetDecodeBuffer ¶
func (*Context) GetDecodeCmd ¶
func (*Context) GetEncodeBuffer ¶
func (*Context) GetEncodeCmd ¶
func (*Context) SetDecodeBuffer ¶
func (*Context) SetDecodeCmd ¶
func (*Context) SetEncodeBuffer ¶
func (*Context) SetEncodeCmd ¶
type ContextCallback ¶
type ProtocolConfig ¶
type ProtocolConfig struct { VmConfig *v2.WasmVmConfig `json:"vm_config,omitempty"` InstanceNum int `json:"instance_num,omitempty"` SubProtocol string `json:"protocol,omitempty"` FromWasmPlugin string `json:"from_wasm_plugin,omitempty"` RootContextID int32 `json:"root_id,omitempty"` PoolMode string `json:"pool_mode,omitempty"` DisableWorkerPool bool `json:"disable_worker_pool,omitempty"` PluginGenerateID bool `json:"plugin_generate_id,omitempty"` // contains filtered or unexported fields }
func ParseProtocolConfig ¶
func ParseProtocolConfig(cfg map[string]interface{}) (*ProtocolConfig, error)
type ProxyProtocolManager ¶
type ProxyProtocolManager interface { // AddOrUpdateProtocolConfig map the key to streamFilter chain wrapper. AddOrUpdateProtocolConfig(config map[string]interface{}) error // GetWasmProtocolFactory return StreamFilterFactory indexed by key. GetWasmProtocolFactory(key string) ProxyProtocolWrapper }
func GetProxyProtocolManager ¶
func GetProxyProtocolManager() ProxyProtocolManager
type ProxyProtocolWrapper ¶
type ProxyProtocolWrapper interface {
Name() string
}
type Request ¶
type Request struct { RequestHeader Data types.IoBuffer // wrapper of data PayLoad types.IoBuffer // wrapper of payload PayloadChanged bool // check if payload if modified // contains filtered or unexported fields }
func NewWasmRequestWithId ¶
func (*Request) GetRequestId ¶
func (*Request) GetStreamType ¶
func (r *Request) GetStreamType() api.StreamType
func (*Request) GetTimeout ¶
func (*Request) IsHeartbeatFrame ¶
func (*Request) SetRequestId ¶
type RequestHeader ¶
func (*RequestHeader) Clone ¶
func (h *RequestHeader) Clone() types.HeaderMap
type Response ¶
type Response struct { ResponseHeader Data types.IoBuffer // wrapper of data PayLoad types.IoBuffer // wrapper of payload PayloadChanged bool // check if payload if modified // contains filtered or unexported fields }
func NewWasmResponseWithId ¶
func (*Response) GetRequestId ¶
func (*Response) GetStatusCode ¶
func (*Response) GetStreamType ¶
func (r *Response) GetStreamType() api.StreamType
func (*Response) GetTimeout ¶
func (*Response) IsHeartbeatFrame ¶
func (*Response) SetRequestId ¶
type ResponseHeader ¶
func (*ResponseHeader) Clone ¶
func (h *ResponseHeader) Clone() types.HeaderMap
Click to show internal directories.
Click to hide internal directories.