bolt

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 15 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 Request

type Request struct {
	RequestHeader

	Data    types.IoBuffer // wrapper of raw data
	Content types.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 types.HeaderMap, data types.IoBuffer) *Request

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

func (*Request) GetData

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

func (*Request) GetHeader

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

func (*Request) GetRequestId

func (r *Request) GetRequestId() uint64

~ XFrame

func (*Request) GetStreamType

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

func (*Request) IsHeartbeatFrame

func (r *Request) IsHeartbeatFrame() bool

func (*Request) SetData

func (r *Request) SetData(data types.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
	xprotocol.Header
}

RequestHeader is the header part of bolt v1 request

func (*RequestHeader) Clone

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

~ HeaderMap

type Response

type Response struct {
	ResponseHeader

	Data    types.IoBuffer // wrapper of raw data
	Content types.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 types.HeaderMap, data types.IoBuffer) *Response

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

func (*Response) GetData

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

func (*Response) GetHeader

func (r *Response) GetHeader() types.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() xprotocol.StreamType

func (*Response) IsHeartbeatFrame

func (r *Response) IsHeartbeatFrame() bool

func (*Response) SetData

func (r *Response) SetData(data types.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
	xprotocol.Header
}

RequestHeader is the header part of bolt v1 response

func (*ResponseHeader) Clone

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

~ HeaderMap

Jump to

Keyboard shortcuts

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