dubbo

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 (
	HeaderLen   = 16
	IdLen       = 8
	MagicIdx    = 0
	FlagIdx     = 2
	StatusIdx   = 3
	IdIdx       = 4
	DataLenIdx  = 12
	DataLenSize = 4
)

dubbo protocol

View Source
const (
	CmdTypeResponse      byte   = 0 // cmd type
	CmdTypeRequest       byte   = 1
	CmdTypeRequestOneway byte   = 2
	UnKnownCmdType       string = "unknown cmd type"
)

req/resp type

View Source
const (
	RespStatusOK                             = 20
	RespStatusClientTimeout                  = 30
	RespStatusServerTimeout                  = 31
	RespStatusBadRequest                     = 40
	RespStatusBadResponse                    = 50
	RespStatusServiceNotFound                = 60
	RespStatusServiceError                   = 70
	RespStatusServerError                    = 80
	RespStatusClientError                    = 90
	RespStatusServerThreadpoolExhaustedError = 100
)

* https://dubbo.apache.org/zh/docs/v2.7/dev/implementation/#%E8%BF%9C%E7%A8%8B%E9%80%9A%E8%AE%AF%E7%BB%86%E8%8A%82 * 20 - OK * 30 - CLIENT_TIMEOUT * 31 - SERVER_TIMEOUT * 40 - BAD_REQUEST * 50 - BAD_RESPONSE * 60 - SERVICE_NOT_FOUND * 70 - SERVICE_ERROR * 80 - SERVER_ERROR * 90 - CLIENT_ERROR * 100 - SERVER_THREADPOOL_EXHAUSTED_ERROR

View Source
const (
	EventRequest  int = 1 // request
	EventResponse int = 0 // response
)
View Source
const (
	FrameworkVersionNameHeader string = "dubbo"
	ServiceNameHeader          string = "service"
	MethodNameHeader           string = "method"
	VersionNameHeader          string = "version"
	GroupNameHeader            string = "group"
	InterfaceNameHeader        string = "interface"
)
View Source
const (
	EgressDubbo  string = "egress_dubbo"
	IngressDubbo string = "ingress_dubbo"
)
View Source
const (
	RESPONSE_WITH_EXCEPTION                  = 0
	RESPONSE_VALUE                           = 1
	RESPONSE_NULL_VALUE                      = 2
	RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS = 3
	RESPONSE_VALUE_WITH_ATTACHMENTS          = 4
	RESPONSE_NULL_VALUE_WITH_ATTACHMENTS     = 5
)

dubbo response code

View Source
const (
	ProtocolName = "dubbo"
)
View Source
const (
	ResponseStatusSuccess uint16 = 0x14 // 0x14 response status
)

Variables

View Source
var MagicTag = []byte{0xda, 0xbb}

* * https://dubbo.apache.org/zh/docs/v2.7/dev/implementation/#%E8%BF%9C%E7%A8%8B%E9%80%9A%E8%AE%AF%E7%BB%86%E8%8A%82 * Dubbo protocol * Request & Response: (byte) * 0 1 2 3 4 5 6 7 8 * +-----------+-----------+-----------+-----------+-----------------------------------------------+ * |magic high | magic low | flag | status | id | * +-----------+-----------+----+------+-----------------------------------------------------------+ * | id | | data length | * +-----------------------------------------------+-----------------------------------------------+ * | | payload | * +-----------------------------------------------------------------------------------------------+ * magic: 0xdabb | * | * | * +--------------------------+ * | * v * flag: (bit offset) * 8 7 6 5 4 3 2 1 0 * +-----------+-----------+-----------+-----------------------------------------------------------+ * | req/rsp | two way | event | serialization id | * +-----------+-----------+-----------+-----------------------------------------------------------+ * event: 1 mean ping * two way: 1 mean req & rsp pair * req/rsp: 1 mean req

Functions

func EncodeRequestType

func EncodeRequestType(tp string) string

func HeadGetDefault

func HeadGetDefault(headers api.HeaderMap, key string, defaultValue string) string

func Matcher

func Matcher(data []byte) api.MatchResult

predicate dubbo header len and compare magic number

Types

type DubboProtocol

type DubboProtocol struct{}

func (DubboProtocol) Decode

func (proto DubboProtocol) Decode(ctx context.Context, data api.IoBuffer) (interface{}, error)

func (DubboProtocol) EnableWorkerPool

func (proto DubboProtocol) EnableWorkerPool() bool

func (DubboProtocol) Encode

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

func (DubboProtocol) GenerateRequestID

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

func (DubboProtocol) Mapping

func (proto DubboProtocol) Mapping(httpStatusCode uint32) uint32

func (DubboProtocol) Name

func (proto DubboProtocol) Name() api.ProtocolName

func (DubboProtocol) PoolMode

func (proto DubboProtocol) PoolMode() api.PoolMode

PoolMode returns whether pingpong or multiplex

func (DubboProtocol) Reply

func (proto DubboProtocol) Reply(ctx context.Context, request api.XFrame) api.XRespFrame

func (DubboProtocol) Trigger

func (proto DubboProtocol) Trigger(ctx context.Context, requestId uint64) api.XFrame

heartbeater

type Frame

type Frame struct {
	Header
	// contains filtered or unexported fields
}

func NewRpcRequest

func NewRpcRequest(headers api.HeaderMap, data api.IoBuffer) *Frame

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

func NewRpcResponse

func NewRpcResponse(headers api.HeaderMap, data api.IoBuffer) *Frame

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

func (*Frame) Clone

func (r *Frame) Clone() api.HeaderMap

func (*Frame) GetData

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

func (*Frame) GetHeader

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

func (*Frame) GetRequestId

func (r *Frame) GetRequestId() uint64

~ XFrame

func (*Frame) GetStatusCode

func (r *Frame) GetStatusCode() uint32

func (*Frame) GetStreamType

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

func (*Frame) GetTimeout

func (r *Frame) GetTimeout() int32

dubbo frame returns default timeout TODO: use dubbo timeout?

func (*Frame) IsHeartbeatFrame

func (r *Frame) IsHeartbeatFrame() bool

func (*Frame) SetData

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

func (*Frame) SetRequestId

func (r *Frame) SetRequestId(id uint64)
type Header struct {
	Magic   []byte
	Flag    byte
	Status  byte
	Id      uint64
	DataLen uint32

	IsEvent         bool // true: heartbeat or readonly event
	IsTwoWay        bool // true: send request and expect response, false: just request without response
	Direction       int  // 1 mean req
	SerializationId int  // 2 mean hessian
	common.Header
}

type Parameter

type Parameter struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

func DecodeParams

func DecodeParams(paramsTypes string, i [][]byte) ([]Parameter, error)

type StatusMapping

type StatusMapping struct{}

func (StatusMapping) MappingHeaderStatusCode

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

Jump to

Keyboard shortcuts

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