xprotocol

package
v0.0.0-...-78a648b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Engine

func Engine() types.ProtocolEngine

func Register

func Register(prot SubProtocol, factory CodecFactory)

Register SubProtocol Plugin

Types

type CodecFactory

type CodecFactory interface {
	CreateSubProtocolCodec(context context.Context) Multiplexing
}

CodecFactory subprotocol plugin factory

type Coder

type Coder struct {
}

Coder types.Encoder types.Decoder

func (*Coder) Decode

func (coder *Coder) Decode(ctx context.Context, data types.IoBuffer) (interface{}, error)

func (*Coder) Encode

func (coder *Coder) Encode(ctx context.Context, model interface{}) (types.IoBuffer, error)

type Multiplexing

type Multiplexing interface {
	SplitFrame(data []byte) [][]byte
	GetStreamID(data []byte) string
	SetStreamID(data []byte, streamID string) []byte
}

Multiplexing Accesslog Rate limit Curcuit Breakers

func CreateSubProtocolCodec

func CreateSubProtocolCodec(context context.Context, prot SubProtocol) Multiplexing

CreateSubProtocolCodec return SubProtocol Client

type ProtocolConvertor

type ProtocolConvertor interface {
	Multiplexing
	Convert(data []byte) (map[string]string, []byte)
}

ProtocolConvertor change protocol base on Multiplexing

type RequestRouting

type RequestRouting interface {
	Multiplexing
	GetMetas(data []byte) map[string]string
}

RequestRouting RequestAccessControl RequesstFaultInjection base on Multiplexing

type SubProtocol

type SubProtocol string

SubProtocol Name

type Tracing

type Tracing interface {
	Multiplexing
	GetServiceName(data []byte) string
	GetMethodName(data []byte) string
}

Tracing base on Multiplexing

type XCmd

type XCmd interface {
	rpc.RpcCmd

	//Tracing
	GetServiceName(data []byte) string
	GetMethodName(data []byte) string

	//RequestRouting
	GetMetas(data []byte) map[string]string

	//ProtocolConvertor
	Convert(data []byte) (map[string]string, []byte)
}

type XRpcCmd

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

TODO should change the multiplexing interface to support decode into a data and header XRpcCmd In XProtocol Mode , XRpcCmd is a codec wrapper , so data and header is useless currently

func (*XRpcCmd) ByteSize

func (xRpcCmd *XRpcCmd) ByteSize() (size uint64)

ByteSize return size of HeaderMap

func (*XRpcCmd) Clone

func (xRpcCmd *XRpcCmd) Clone() types.HeaderMap

Clone used to deep copy header's map

func (*XRpcCmd) Convert

func (xRpcCmd *XRpcCmd) Convert(data []byte) (map[string]string, []byte)

ProtocolConvertor

func (*XRpcCmd) Data

func (xRpcCmd *XRpcCmd) Data() types.IoBuffer

Data no use util we change multiplexing interface

func (*XRpcCmd) Del

func (xRpcCmd *XRpcCmd) Del(key string)

Del delete pair of specified key

func (*XRpcCmd) Get

func (xRpcCmd *XRpcCmd) Get(key string) (value string, ok bool)

func (*XRpcCmd) GetMetas

func (xRpcCmd *XRpcCmd) GetMetas(data []byte) map[string]string

RequestRouting

func (*XRpcCmd) GetMethodName

func (xRpcCmd *XRpcCmd) GetMethodName(data []byte) string

func (*XRpcCmd) GetServiceName

func (xRpcCmd *XRpcCmd) GetServiceName(data []byte) string

Tracing

func (*XRpcCmd) GetStreamID

func (xRpcCmd *XRpcCmd) GetStreamID(data []byte) string

func (*XRpcCmd) Header

func (xRpcCmd *XRpcCmd) Header() map[string]string

Header no use util we change multiplexing interface

func (*XRpcCmd) ProtocolCode

func (xRpcCmd *XRpcCmd) ProtocolCode() byte

ProtocolEngine no use util we change multiplexing interface

func (*XRpcCmd) Range

func (xRpcCmd *XRpcCmd) Range(f func(key, value string) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*XRpcCmd) RequestID

func (xRpcCmd *XRpcCmd) RequestID() uint64

RequestID no use util we change multiplexing interface

func (*XRpcCmd) Set

func (xRpcCmd *XRpcCmd) Set(key string, value string)

Set key-value pair in header map, the previous pair will be replaced if exists

func (*XRpcCmd) SetData

func (xRpcCmd *XRpcCmd) SetData(data types.IoBuffer)

SetData no use util we change multiplexing interface

func (*XRpcCmd) SetHeader

func (xRpcCmd *XRpcCmd) SetHeader(header map[string]string)

SetHeader no use util we change multiplexing interface

func (*XRpcCmd) SetRequestID

func (xRpcCmd *XRpcCmd) SetRequestID(requestID uint64)

SetRequestID no use util we change multiplexing interface

func (*XRpcCmd) SetStreamID

func (xRpcCmd *XRpcCmd) SetStreamID(data []byte, streamID string) []byte

func (*XRpcCmd) SplitFrame

func (xRpcCmd *XRpcCmd) SplitFrame(data []byte) [][]byte

Multiplexing

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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