bolt

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ProtocolName    types.ProtocolName = "bolt" // protocol
	ProtocolCode    byte               = 1
	ProtocolVersion byte               = 1

	CmdTypeResponse      byte = 0 // cmd type
	CmdTypeRequest       byte = 1
	CmdTypeRequestOneway byte = 2

	CmdCodeHeartbeat   uint16 = 0 // cmd code
	CmdCodeRpcRequest  uint16 = 1
	CmdCodeRpcResponse uint16 = 2

	Hessian2Serialize byte = 1 // serialize

	ResponseStatusSuccess                 uint16 = 0  // 0x00 response status
	ResponseStatusError                   uint16 = 1  // 0x01
	ResponseStatusServerException         uint16 = 2  // 0x02
	ResponseStatusUnknown                 uint16 = 3  // 0x03
	ResponseStatusServerThreadpoolBusy    uint16 = 4  // 0x04
	ResponseStatusErrorComm               uint16 = 5  // 0x05
	ResponseStatusNoProcessor             uint16 = 6  // 0x06
	ResponseStatusTimeout                 uint16 = 7  // 0x07
	ResponseStatusClientSendError         uint16 = 8  // 0x08
	ResponseStatusCodecException          uint16 = 9  // 0x09
	ResponseStatusConnectionClosed        uint16 = 16 // 0x10
	ResponseStatusServerSerialException   uint16 = 17 // 0x11
	ResponseStatusServerDeserialException uint16 = 18 // 0x12

	RequestHeaderLen  int = 22 // protocol header fields length
	ResponseHeaderLen int = 20
	LessLen           int = ResponseHeaderLen // minimal length for decoding

	RequestIdIndex         = 5
	RequestHeaderLenIndex  = 16
	ResponseHeaderLenIndex = 14
)

bolt constants

View Source
const (
	// Encode/Decode Exception Msg
	UnKnownCmdType string = "unknown cmd type"
	UnKnownCmdCode string = "unknown cmd code"

	// Sofa Rpc Default HC Parameters
	SofaRPC                             = "SofaRpc"
	DefaultBoltHeartBeatTimeout         = 6 * 15 * time.Second
	DefaultBoltHeartBeatInterval        = 15 * time.Second
	DefaultIntervalJitter               = 5 * time.Millisecond
	DefaultHealthyThreshold      uint32 = 2
	DefaultUnhealthyThreshold    uint32 = 2
)

Variables

View Source
var (
	// Encode/Decode Exception
	ErrUnKnownCmdType = errors.New(UnKnownCmdType)
	ErrUnKnownCmdCode = errors.New(UnKnownCmdCode)
)
View Source
var DefaultSofaRPCHealthCheckConf = v2.HealthCheck{
	HealthCheckConfig: v2.HealthCheckConfig{
		Protocol:           SofaRPC,
		HealthyThreshold:   DefaultHealthyThreshold,
		UnhealthyThreshold: DefaultUnhealthyThreshold,
	},
	Timeout:        DefaultBoltHeartBeatTimeout,
	Interval:       DefaultBoltHeartBeatInterval,
	IntervalJitter: DefaultIntervalJitter,
}

DefaultSofaRPCHealthCheckConf

Functions

This section is empty.

Types

type BoltStatusMapping added in v0.26.0

type BoltStatusMapping struct{}

func (BoltStatusMapping) MappingHeaderStatusCode added in v0.26.0

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

type Request

type Request struct {
	RequestHeader

	Data    api.IoBuffer // wrapper of raw data
	Content api.IoBuffer // wrapper of raw content

	ContentChanged bool // indicate that content changed
	// contains filtered or unexported fields
}

Request is the cmd struct of bolt v1 request

func NewRpcRequest

func NewRpcRequest(requestId uint32, headers api.HeaderMap, data api.IoBuffer) *Request

NewRpcRequest is a utility function which build rpc Request object of bolt 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

~ XFrame

func (*Request) GetStreamType

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

func (*Request) GetTimeout added in v0.22.0

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 RequestHeader

type RequestHeader struct {
	Protocol   byte // meta fields
	CmdType    byte
	CmdCode    uint16
	Version    byte
	RequestId  uint32
	Codec      byte
	Timeout    int32
	ClassLen   uint16
	HeaderLen  uint16
	ContentLen uint32

	Class string // payload fields
	header.BytesHeader
}

RequestHeader is the header part of bolt v1 request

func (*RequestHeader) Clone

func (h *RequestHeader) Clone() api.HeaderMap

~ HeaderMap

type Response

type Response struct {
	ResponseHeader

	Data    api.IoBuffer // wrapper of raw data
	Content api.IoBuffer // wrapper of raw content

	ContentChanged bool // indicate that content changed
	// contains filtered or unexported fields
}

Response is the cmd struct of bolt v1 response

func NewRpcResponse

func NewRpcResponse(requestId uint32, statusCode uint16, headers api.HeaderMap, data api.IoBuffer) *Response

NewRpcResponse is a utility function which build rpc Response object of bolt 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

~ XRespFrame

func (*Response) GetStatusCode

func (r *Response) GetStatusCode() uint32

func (*Response) GetStreamType

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

func (*Response) GetTimeout added in v0.22.0

func (r *Response) GetTimeout() int32

response contains no timeout

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 ResponseHeader

type ResponseHeader struct {
	Protocol       byte // meta fields
	CmdType        byte
	CmdCode        uint16
	Version        byte
	RequestId      uint32
	Codec          byte
	ResponseStatus uint16
	ClassLen       uint16
	HeaderLen      uint16
	ContentLen     uint32

	Class string // payload fields
	header.BytesHeader
}

RequestHeader is the header part of bolt v1 response

func (*ResponseHeader) Clone

func (h *ResponseHeader) Clone() api.HeaderMap

~ HeaderMap

type XCodec added in v0.26.0

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

func (*XCodec) HTTPMapping added in v0.26.0

func (codec *XCodec) HTTPMapping() api.HTTPMapping

func (*XCodec) NewXProtocol added in v0.26.0

func (codec *XCodec) NewXProtocol(_ context.Context) api.XProtocol

func (*XCodec) ProtocolMatch added in v0.26.0

func (codec *XCodec) ProtocolMatch() api.ProtocolMatch

func (*XCodec) ProtocolName added in v0.26.0

func (codec *XCodec) ProtocolName() api.ProtocolName

Jump to

Keyboard shortcuts

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