Documentation
¶
Overview ¶
Copyright 2022 Huawei Cloud Computing Technologies Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func ConnPoolSize() int
- func DefaultConfiguration() config.Spdy
- func HandleError(err error)
- func MultiplexedSessionFuture(f func() (*MultiplexedSession, error)) func() (*MultiplexedSession, error)
- func SetDefaultConfiguration(cfg config.Spdy)
- func SetTCPDialTimeout(timeout time.Duration)
- func TCPDialTimeout() time.Duration
- type BaseError
- type BaseEventHandler
- type BaseRequester
- func (base *BaseRequester) FinishAnalyze()
- func (base *BaseRequester) InitDerive(session *MultiplexedSession, sequence uint64, derive Requester)
- func (base *BaseRequester) Request(request interface{}) error
- func (base *BaseRequester) Sequence() uint64
- func (base *BaseRequester) Session() *MultiplexedSession
- func (base *BaseRequester) StartAnalyze(span *tracing.Span)
- type BaseResponser
- func (base *BaseResponser) Apply() error
- func (base *BaseResponser) Close() error
- func (base *BaseResponser) FinishAnalyze()
- func (base *BaseResponser) InitDerive(session *MultiplexedSession, sequence uint64, derive Responser)
- func (base *BaseResponser) IsFull() bool
- func (base *BaseResponser) Response(response interface{}, full bool) error
- func (base *BaseResponser) Sequence() uint64
- func (base *BaseResponser) Session() *MultiplexedSession
- func (base *BaseResponser) StartAnalyze(span *tracing.Span)
- type BuffWriter
- type Closer
- type Codec
- type DataACK
- type EventHandler
- type EventHandlerFactory
- type FSM
- type FSMError
- type FSMEventAction
- type FSMState
- type FSMStateAction
- type FSMTransition
- type Flags
- type InternalError
- type MultiplexedConnection
- func (c *MultiplexedConnection) AcceptSession() func() (*MultiplexedSession, error)
- func (c *MultiplexedConnection) AllocData(n int) []byte
- func (c *MultiplexedConnection) Close() error
- func (c *MultiplexedConnection) FreeData(data []byte)
- func (c *MultiplexedConnection) IsClosed() bool
- func (c *MultiplexedConnection) ListenAndServed() error
- func (c *MultiplexedConnection) LocalAddr() net.Addr
- func (c *MultiplexedConnection) NumOfSession() int
- func (c *MultiplexedConnection) OpenSession() func() (*MultiplexedSession, error)
- func (c *MultiplexedConnection) RemoteAddr() net.Addr
- func (c *MultiplexedConnection) Write(hdr []byte, data []byte) error
- type MultiplexedError
- type MultiplexedServer
- type MultiplexedSession
- func (s *MultiplexedSession) Close() error
- func (s *MultiplexedSession) Connection() *MultiplexedConnection
- func (s *MultiplexedSession) DisableDataACK()
- func (s *MultiplexedSession) EnableDataACK()
- func (s *MultiplexedSession) GenerateNextSequence() uint64
- func (s *MultiplexedSession) Handle(flags uint16, data []byte) error
- func (s *MultiplexedSession) ID() uint64
- func (s *MultiplexedSession) IsClosed() bool
- func (s *MultiplexedSession) Open(ackSig chan struct{}) error
- func (s *MultiplexedSession) RecvAck() error
- func (s *MultiplexedSession) RecvData(data []byte) error
- func (s *MultiplexedSession) RecvDataACK() error
- func (s *MultiplexedSession) RecvFin() error
- func (s *MultiplexedSession) RecvRst() error
- func (s *MultiplexedSession) RecvSyn() error
- func (s *MultiplexedSession) Select() ([]byte, error)
- func (s *MultiplexedSession) Send(data []byte) error
- func (s *MultiplexedSession) SendAck(data []byte) error
- func (s *MultiplexedSession) SendDataACK(data []byte) error
- func (s *MultiplexedSession) SendFin(data []byte) error
- func (s *MultiplexedSession) SendRst(data []byte) error
- func (s *MultiplexedSession) SendSyn(data []byte, ackRecvSig chan struct{}) error
- func (s *MultiplexedSession) SetOnClose(fn func())
- func (s *MultiplexedSession) SetTimeout(d time.Duration)
- func (s *MultiplexedSession) State() state
- func (s *MultiplexedSession) TriggerOnClose()
- type MultiplexedSessionPool
- func (c *MultiplexedSessionPool) Available() bool
- func (c *MultiplexedSessionPool) Close()
- func (c *MultiplexedSessionPool) Dial() error
- func (c *MultiplexedSessionPool) Get() (*MultiplexedSession, error)
- func (c *MultiplexedSessionPool) IsClosed() bool
- func (c *MultiplexedSessionPool) Put(session *MultiplexedSession)
- func (c *MultiplexedSessionPool) SetStatisticsJob(job *statistics.SpdyJob)
- func (c *MultiplexedSessionPool) Wait()
- type ProtocolHeader
- type RRCServer
- type Reactor
- type Requester
- type Responser
- type Selector
- type SessionRole
- type TransitionTable
Constants ¶
View Source
const ( INTERNAL_ERROR = iota FSM_ERROR )
View Source
const ( SEND_SYN_EVENT event = iota RECV_SYN_EVENT SEND_ACK_EVENT RECV_ACK_EVENT SEND_DATA_EVENT RECV_DATA_EVENT SEND_FIN_EVENT RECV_FIN_EVENT SEND_RST_EVENT RECV_RST_EVENT SEND_DATA_ACK_EVENT RECV_DATA_ACK_EVENT UNKNOWN_EVENT )
View Source
const ( INIT_STATE state = iota SYN_SENT_STATE SYN_RECV_STATE ESTABLISHED_STATE FIN_SENT_STATE FIN_RECV_STATE CLOSED_STATE UNKNOWN_STATE )
View Source
const ( SIZE_OF_VERSION = 1 SIZE_OF_TYPE = 1 SIZE_OF_FLAGS = 2 SIZE_OF_CONNID = 8 SIZE_OF_LENGTH = 4 HEADER_SIZE = SIZE_OF_VERSION + SIZE_OF_TYPE + SIZE_OF_FLAGS + SIZE_OF_CONNID + SIZE_OF_LENGTH )
View Source
const ( DATA_TYPE uint8 = iota CLOSE_TYPE UNKNOWN_TYPE )
View Source
const ( SYN_FLAG uint16 = 1 << iota ACK_FLAG FIN_FLAG RST_FLAG DATA_ACK_FLAG )
View Source
const ( ProtocolVersion uint8 = 0 SizeOfProtocolVersion = 1 SizeOfProtocolType = 1 SizeOfProtocolFlags = 2 SizeOfProtocolSequence = 8 SizeOfProtocolLength = 4 ProtocolHeaderSize = SizeOfProtocolVersion + SizeOfProtocolType + SizeOfProtocolFlags + SizeOfProtocolSequence + SizeOfProtocolLength )
View Source
const ( ReqFlag uint16 = 1 << iota RspFlag FullFlag )
View Source
const ( Prototype uint8 = iota Echo Partial FaultPartial SelectRequest AbortRequest DDLRequest SysCtrlRequest MetaRequest WritePointsRequest PtRequest WriteStreamPointsRequest SegregateNodeRequest TransferLeadershipRequest CrashRequest RaftMsgRequest Unknown )
View Source
const (
SPDY_VERSION uint8 = 0
)
Variables ¶
View Source
var ( ErrorInvalidProtocolVersion = NewInternalError(INTERNAL_ERROR, "invalid protocol version") ErrorInvalidProtocolType = NewInternalError(INTERNAL_ERROR, "invalid protocol type") ErrorUnexpectedResponse = NewInternalError(INTERNAL_ERROR, "unexpected response") ErrorUnexpectedRequest = NewInternalError(INTERNAL_ERROR, "unexpected request") )
Functions ¶
func ConnPoolSize ¶
func ConnPoolSize() int
func DefaultConfiguration ¶
DefaultConfiguration is used to return a default configuration
func HandleError ¶
func HandleError(err error)
func MultiplexedSessionFuture ¶
func MultiplexedSessionFuture(f func() (*MultiplexedSession, error)) func() (*MultiplexedSession, error)
func SetDefaultConfiguration ¶
func SetTCPDialTimeout ¶ added in v1.0.1
func TCPDialTimeout ¶ added in v1.0.1
Types ¶
type BaseEventHandler ¶
type BaseEventHandler struct {
// contains filtered or unexported fields
}
func (*BaseEventHandler) InitDerive ¶
func (base *BaseEventHandler) InitDerive(session *MultiplexedSession, derive EventHandler)
func (*BaseEventHandler) Session ¶
func (base *BaseEventHandler) Session() *MultiplexedSession
func (*BaseEventHandler) WarpRequester ¶
func (base *BaseEventHandler) WarpRequester(sequence uint64, data []byte) (Requester, error)
type BaseRequester ¶
type BaseRequester struct {
// contains filtered or unexported fields
}
func (*BaseRequester) FinishAnalyze ¶
func (base *BaseRequester) FinishAnalyze()
func (*BaseRequester) InitDerive ¶
func (base *BaseRequester) InitDerive(session *MultiplexedSession, sequence uint64, derive Requester)
func (*BaseRequester) Request ¶
func (base *BaseRequester) Request(request interface{}) error
func (*BaseRequester) Sequence ¶
func (base *BaseRequester) Sequence() uint64
func (*BaseRequester) Session ¶
func (base *BaseRequester) Session() *MultiplexedSession
func (*BaseRequester) StartAnalyze ¶
func (base *BaseRequester) StartAnalyze(span *tracing.Span)
type BaseResponser ¶
type BaseResponser struct {
// contains filtered or unexported fields
}
func (*BaseResponser) Apply ¶
func (base *BaseResponser) Apply() error
func (*BaseResponser) Close ¶
func (base *BaseResponser) Close() error
func (*BaseResponser) FinishAnalyze ¶
func (base *BaseResponser) FinishAnalyze()
func (*BaseResponser) InitDerive ¶
func (base *BaseResponser) InitDerive(session *MultiplexedSession, sequence uint64, derive Responser)
func (*BaseResponser) IsFull ¶
func (base *BaseResponser) IsFull() bool
func (*BaseResponser) Response ¶
func (base *BaseResponser) Response(response interface{}, full bool) error
func (*BaseResponser) Sequence ¶
func (base *BaseResponser) Sequence() uint64
func (*BaseResponser) Session ¶
func (base *BaseResponser) Session() *MultiplexedSession
func (*BaseResponser) StartAnalyze ¶
func (base *BaseResponser) StartAnalyze(span *tracing.Span)
type BuffWriter ¶ added in v1.0.0
type DataACK ¶
type DataACK struct {
// contains filtered or unexported fields
}
func NewDataACK ¶
func (*DataACK) SetBlockTimeout ¶
func (*DataACK) SetRole ¶
func (a *DataACK) SetRole(role SessionRole)
type EventHandler ¶
type EventHandlerFactory ¶
type EventHandlerFactory interface { CreateEventHandler(session *MultiplexedSession) EventHandler EventHandlerType() uint8 }
type FSM ¶
type FSM struct {
// contains filtered or unexported fields
}
func (*FSM) Build ¶
func (fsm *FSM) Build(start *FSMState, event event, next *FSMState, action FSMEventAction)
func (*FSM) ForceSetState ¶
func (fsm *FSM) ForceSetState(state state)
func (*FSM) ProcessEvent ¶
type FSMError ¶
type FSMError struct { BaseError // contains filtered or unexported fields }
func NewFSMError ¶
func NewFSMError(event event, state state) *FSMError
type FSMEventAction ¶
type FSMEventAction func(event, *FSMTransition, []byte) error
type FSMState ¶
type FSMState struct {
// contains filtered or unexported fields
}
func NewFSMState ¶
func NewFSMState(state state, enterAction FSMStateAction, exitAction FSMStateAction) *FSMState
type FSMStateAction ¶
type FSMStateAction func(event, *FSMTransition) error
type FSMTransition ¶
type FSMTransition struct {
// contains filtered or unexported fields
}
func NewFSMTransition ¶
func NewFSMTransition(start *FSMState, event event, next *FSMState, action FSMEventAction) *FSMTransition
type InternalError ¶
type InternalError struct { BaseError // contains filtered or unexported fields }
func NewInternalError ¶
func NewInternalError(code uint32, msg string) *InternalError
func (*InternalError) Error ¶
func (e *InternalError) Error() string
func (*InternalError) Msg ¶
func (e *InternalError) Msg() string
type MultiplexedConnection ¶
type MultiplexedConnection struct {
// contains filtered or unexported fields
}
func NewMultiplexedConnection ¶
func NewMultiplexedConnection(cfg config.Spdy, underlying io.ReadWriteCloser, client bool) *MultiplexedConnection
func (*MultiplexedConnection) AcceptSession ¶
func (c *MultiplexedConnection) AcceptSession() func() (*MultiplexedSession, error)
func (*MultiplexedConnection) AllocData ¶
func (c *MultiplexedConnection) AllocData(n int) []byte
func (*MultiplexedConnection) Close ¶
func (c *MultiplexedConnection) Close() error
func (*MultiplexedConnection) FreeData ¶
func (c *MultiplexedConnection) FreeData(data []byte)
func (*MultiplexedConnection) IsClosed ¶
func (c *MultiplexedConnection) IsClosed() bool
func (*MultiplexedConnection) ListenAndServed ¶
func (c *MultiplexedConnection) ListenAndServed() error
func (*MultiplexedConnection) LocalAddr ¶
func (c *MultiplexedConnection) LocalAddr() net.Addr
func (*MultiplexedConnection) NumOfSession ¶
func (c *MultiplexedConnection) NumOfSession() int
func (*MultiplexedConnection) OpenSession ¶
func (c *MultiplexedConnection) OpenSession() func() (*MultiplexedSession, error)
func (*MultiplexedConnection) RemoteAddr ¶
func (c *MultiplexedConnection) RemoteAddr() net.Addr
type MultiplexedError ¶
type MultiplexedServer ¶
type MultiplexedServer struct {
// contains filtered or unexported fields
}
func (*MultiplexedServer) Error ¶
func (s *MultiplexedServer) Error() error
func (*MultiplexedServer) Start ¶
func (s *MultiplexedServer) Start()
func (*MultiplexedServer) Stop ¶
func (s *MultiplexedServer) Stop()
type MultiplexedSession ¶
type MultiplexedSession struct {
// contains filtered or unexported fields
}
func NewMultiplexedSession ¶
func NewMultiplexedSession(cfg config.Spdy, conn *MultiplexedConnection, id uint64) *MultiplexedSession
func (*MultiplexedSession) Close ¶
func (s *MultiplexedSession) Close() error
func (*MultiplexedSession) Connection ¶
func (s *MultiplexedSession) Connection() *MultiplexedConnection
func (*MultiplexedSession) DisableDataACK ¶
func (s *MultiplexedSession) DisableDataACK()
func (*MultiplexedSession) EnableDataACK ¶
func (s *MultiplexedSession) EnableDataACK()
func (*MultiplexedSession) GenerateNextSequence ¶
func (s *MultiplexedSession) GenerateNextSequence() uint64
func (*MultiplexedSession) Handle ¶
func (s *MultiplexedSession) Handle(flags uint16, data []byte) error
func (*MultiplexedSession) ID ¶
func (s *MultiplexedSession) ID() uint64
func (*MultiplexedSession) IsClosed ¶
func (s *MultiplexedSession) IsClosed() bool
func (*MultiplexedSession) Open ¶
func (s *MultiplexedSession) Open(ackSig chan struct{}) error
func (*MultiplexedSession) RecvAck ¶
func (s *MultiplexedSession) RecvAck() error
func (*MultiplexedSession) RecvData ¶
func (s *MultiplexedSession) RecvData(data []byte) error
func (*MultiplexedSession) RecvDataACK ¶
func (s *MultiplexedSession) RecvDataACK() error
func (*MultiplexedSession) RecvFin ¶
func (s *MultiplexedSession) RecvFin() error
func (*MultiplexedSession) RecvRst ¶
func (s *MultiplexedSession) RecvRst() error
func (*MultiplexedSession) RecvSyn ¶
func (s *MultiplexedSession) RecvSyn() error
func (*MultiplexedSession) Select ¶
func (s *MultiplexedSession) Select() ([]byte, error)
func (*MultiplexedSession) Send ¶
func (s *MultiplexedSession) Send(data []byte) error
func (*MultiplexedSession) SendAck ¶
func (s *MultiplexedSession) SendAck(data []byte) error
func (*MultiplexedSession) SendDataACK ¶
func (s *MultiplexedSession) SendDataACK(data []byte) error
func (*MultiplexedSession) SendFin ¶
func (s *MultiplexedSession) SendFin(data []byte) error
func (*MultiplexedSession) SendRst ¶
func (s *MultiplexedSession) SendRst(data []byte) error
func (*MultiplexedSession) SendSyn ¶
func (s *MultiplexedSession) SendSyn(data []byte, ackRecvSig chan struct{}) error
func (*MultiplexedSession) SetOnClose ¶
func (s *MultiplexedSession) SetOnClose(fn func())
func (*MultiplexedSession) SetTimeout ¶
func (s *MultiplexedSession) SetTimeout(d time.Duration)
func (*MultiplexedSession) State ¶
func (s *MultiplexedSession) State() state
func (*MultiplexedSession) TriggerOnClose ¶
func (s *MultiplexedSession) TriggerOnClose()
type MultiplexedSessionPool ¶
type MultiplexedSessionPool struct {
// contains filtered or unexported fields
}
func NewMultiplexedSessionPool ¶
func NewMultiplexedSessionPool(cfg config.Spdy, network string, address string) *MultiplexedSessionPool
func (*MultiplexedSessionPool) Available ¶
func (c *MultiplexedSessionPool) Available() bool
func (*MultiplexedSessionPool) Close ¶
func (c *MultiplexedSessionPool) Close()
func (*MultiplexedSessionPool) Dial ¶
func (c *MultiplexedSessionPool) Dial() error
func (*MultiplexedSessionPool) Get ¶
func (c *MultiplexedSessionPool) Get() (*MultiplexedSession, error)
func (*MultiplexedSessionPool) IsClosed ¶
func (c *MultiplexedSessionPool) IsClosed() bool
func (*MultiplexedSessionPool) Put ¶
func (c *MultiplexedSessionPool) Put(session *MultiplexedSession)
func (*MultiplexedSessionPool) SetStatisticsJob ¶
func (c *MultiplexedSessionPool) SetStatisticsJob(job *statistics.SpdyJob)
func (*MultiplexedSessionPool) Wait ¶
func (c *MultiplexedSessionPool) Wait()
type ProtocolHeader ¶
type ProtocolHeader []byte
func (ProtocolHeader) Flags ¶
func (h ProtocolHeader) Flags() uint16
func (ProtocolHeader) Length ¶
func (h ProtocolHeader) Length() uint32
func (ProtocolHeader) Sequence ¶
func (h ProtocolHeader) Sequence() uint64
func (ProtocolHeader) String ¶
func (h ProtocolHeader) String() string
func (ProtocolHeader) Type ¶
func (h ProtocolHeader) Type() uint8
func (ProtocolHeader) Version ¶
func (h ProtocolHeader) Version() uint8
type RRCServer ¶
type RRCServer struct {
// contains filtered or unexported fields
}
func (*RRCServer) RegisterEHF ¶
func (s *RRCServer) RegisterEHF(factory EventHandlerFactory)
type Reactor ¶
type Reactor struct {
// contains filtered or unexported fields
}
func (*Reactor) HandleEvents ¶
func (r *Reactor) HandleEvents()
type SessionRole ¶
type SessionRole string
const ( RoleClient SessionRole = "client" RoleServer SessionRole = "server" )
type TransitionTable ¶
type TransitionTable struct {
// contains filtered or unexported fields
}
func NewTransitionTable ¶
func NewTransitionTable() *TransitionTable
Source Files
¶
Click to show internal directories.
Click to hide internal directories.