Documentation ¶
Index ¶
- Constants
- Variables
- func DecodePayload(payload *Payload) ([]byte, bool)
- func GlobalRegistry() *registry
- func InitAcker(forwarder PayloadBufferForwarder, metrics metrics.Registry, ...)
- func InitMetrics(registry metrics.UsageRegistry)
- func InitPayloadIngester(closeNotify <-chan struct{})
- func InitRetransmitter(forwarder PayloadBufferForwarder, faultReporter RetransmitterFaultReporter, ...)
- func NewRegistry() *registry
- func ReadUntil(peer transport.Conn, stop byte) ([]byte, error)
- func ReadUntilNewline(peer transport.Conn) ([]byte, error)
- func RemoveTerminator(ctrls networkControllers, terminatorId string) error
- func RemoveTerminators(ctrls networkControllers, terminatorIds []string)
- func RespondToTraceRequest(headers channel.Headers, hopType, hopId string, response ControlReceiver)
- func SendRequest(request *Request, peer io.Writer) error
- func SendResponse(response *Response, peer io.Writer) error
- func SetOriginatorFlag(flags uint32, originator Originator) uint32
- type Acker
- type Acknowledgement
- type Address
- type BindHandler
- type CircuitInfo
- type CloseHandler
- type CloseHandlerF
- type CloseHelper
- type Connection
- type Control
- func (self *Control) CreateTraceResponse(hopType, hopId string) *Control
- func (self *Control) DecrementAndGetHop() uint32
- func (self *Control) GetLoggerFields() logrus.Fields
- func (self *Control) IsTypeTraceRoute() bool
- func (self *Control) IsTypeTraceRouteResponse() bool
- func (self *Control) Marshall() *channel.Message
- type ControlReceiver
- type ControlType
- type Decoder
- type DialParams
- type Dialer
- type Factory
- type Header
- type InvalidTerminatorError
- type LinkReceiveBuffer
- func (buffer *LinkReceiveBuffer) Inspect() *inspect.XgressRecvBufferDetail
- func (buffer *LinkReceiveBuffer) PeekHead() *Payload
- func (buffer *LinkReceiveBuffer) ReceiveUnordered(payload *Payload, maxSize uint32) bool
- func (buffer *LinkReceiveBuffer) Remove(payload *Payload)
- func (buffer *LinkReceiveBuffer) Size() uint32
- type LinkSendBuffer
- func (buffer *LinkSendBuffer) BufferPayload(payload *Payload) (func(), error)
- func (buffer *LinkSendBuffer) Close()
- func (buffer *LinkSendBuffer) CloseWhenEmpty() bool
- func (buffer *LinkSendBuffer) Inspect() *inspect.XgressSendBufferDetail
- func (buffer *LinkSendBuffer) ReceiveAcknowledgement(ack *Acknowledgement)
- type Listener
- type MisconfiguredTerminatorError
- type Options
- type OptionsData
- type Originator
- type Payload
- type PayloadBufferForwarder
- type PayloadFlag
- type PayloadIngester
- type PeekHandler
- type ReceiveHandler
- type Request
- type Response
- type Retransmitter
- type RetransmitterFaultReporter
- type Xgress
- func (self *Xgress) AddCloseHandler(closeHandler CloseHandler)
- func (self *Xgress) AddPeekHandler(peekHandler PeekHandler)
- func (self *Xgress) Address() Address
- func (self *Xgress) CircuitId() string
- func (self *Xgress) Close()
- func (self *Xgress) CloseTimeout(duration time.Duration)
- func (self *Xgress) Closed() bool
- func (self *Xgress) CtrlId() string
- func (self *Xgress) ForwardEndOfCircuit(sendF func(payload *Payload) bool)
- func (self *Xgress) GetEndCircuit() *Payload
- func (self *Xgress) GetIntervalId() string
- func (self *Xgress) GetSequence() int32
- func (self *Xgress) GetStartCircuit() *Payload
- func (self *Xgress) GetTags() map[string]string
- func (self *Xgress) GetTimeOfLastRxFromLink() int64
- func (self *Xgress) HandleControlReceive(controlType ControlType, headers channel.Headers)
- func (self *Xgress) InspectCircuit(detail *inspect.CircuitInspectDetail)
- func (self *Xgress) IsCircuitStarted() bool
- func (self *Xgress) IsEndOfCircuitReceived() bool
- func (self *Xgress) IsEndOfCircuitSent() bool
- func (self *Xgress) IsTerminator() bool
- func (self *Xgress) Label() string
- func (self *Xgress) Originator() Originator
- func (self *Xgress) PayloadReceived(payload *Payload)
- func (self *Xgress) SendAcknowledgement(acknowledgement *Acknowledgement) error
- func (self *Xgress) SendControl(control *Control) error
- func (self *Xgress) SendEmptyAck()
- func (self *Xgress) SendPayload(payload *Payload) error
- func (self *Xgress) SetReceiveHandler(receiveHandler ReceiveHandler)
- func (self *Xgress) Start()
- func (self *Xgress) Unrouted()
Constants ¶
const ( MinHeaderKey = 2000 MaxHeaderKey = MinHeaderKey + int32(math.MaxUint8) HeaderKeyCircuitId = 2256 HeaderKeySequence = 2257 HeaderKeyFlags = 2258 HeaderKeyRecvBufferSize = 2259 HeaderKeyRTT = 2260 ContentTypePayloadType = 1100 ContentTypeAcknowledgementType = 1101 ContentTypeControlType = 1102 )
const ( ControlHopCount = 20 ControlHopType = 21 ControlHopId = 22 ControlTimestamp = 23 ControlUserVal = 24 ControlError = 25 )
const DECODER = "data"
const (
HeaderKeyUUID = 0
)
Variables ¶
var ContentTypeValue = map[string]int32{ "PayloadType": ContentTypePayloadType, "AcknowledgementType": ContentTypeAcknowledgementType, "ControlType": ContentTypeControlType, }
Functions ¶
func DecodePayload ¶
func GlobalRegistry ¶
func GlobalRegistry() *registry
func InitAcker ¶
func InitAcker(forwarder PayloadBufferForwarder, metrics metrics.Registry, closeNotify <-chan struct{})
func InitMetrics ¶
func InitMetrics(registry metrics.UsageRegistry)
func InitPayloadIngester ¶
func InitPayloadIngester(closeNotify <-chan struct{})
func InitRetransmitter ¶
func InitRetransmitter(forwarder PayloadBufferForwarder, faultReporter RetransmitterFaultReporter, metrics metrics.Registry, closeNotify <-chan struct{})
func NewRegistry ¶
func NewRegistry() *registry
func ReadUntilNewline ¶
func RemoveTerminator ¶
func RemoveTerminators ¶
func RemoveTerminators(ctrls networkControllers, terminatorIds []string)
func RespondToTraceRequest ¶
func RespondToTraceRequest(headers channel.Headers, hopType, hopId string, response ControlReceiver)
func SetOriginatorFlag ¶
func SetOriginatorFlag(flags uint32, originator Originator) uint32
Types ¶
type Acker ¶
type Acker struct {
// contains filtered or unexported fields
}
Note: if altering this struct, be sure to account for 64 bit alignment on 32 bit arm arch https://pkg.go.dev/sync/atomic#pkg-note-BUG https://github.com/golang/go/issues/36606
type Acknowledgement ¶
func NewAcknowledgement ¶
func NewAcknowledgement(circuitId string, originator Originator) *Acknowledgement
func UnmarshallAcknowledgement ¶
func UnmarshallAcknowledgement(msg *channel.Message) (*Acknowledgement, error)
func (*Acknowledgement) GetLoggerFields ¶
func (ack *Acknowledgement) GetLoggerFields() logrus.Fields
func (*Acknowledgement) GetSequence ¶
func (ack *Acknowledgement) GetSequence() []int32
func (*Acknowledgement) Marshall ¶
func (ack *Acknowledgement) Marshall() *channel.Message
type BindHandler ¶
type BindHandler interface {
HandleXgressBind(x *Xgress)
}
The BindHandlers are invoked to install the appropriate handlers.
type CircuitInfo ¶
type CircuitInfo struct { CtrlId string CircuitId *identity.TokenId Address Address ResponseMsg *channel.Message }
func GetCircuit ¶
type CloseHandler ¶
type CloseHandler interface { // HandleXgressClose is invoked when the connected peer terminates the communication. // HandleXgressClose(x *Xgress) }
CloseHandler is invoked by an xgress when the connected peer terminates the communication.
type CloseHandlerF ¶
type CloseHandlerF func(x *Xgress)
CloseHandlerF is the function version of CloseHandler
func (CloseHandlerF) HandleXgressClose ¶
func (self CloseHandlerF) HandleXgressClose(x *Xgress)
type CloseHelper ¶
type CloseHelper struct {
// contains filtered or unexported fields
}
func (*CloseHelper) Close ¶
func (self *CloseHelper) Close() error
func (*CloseHelper) Init ¶
func (self *CloseHelper) Init(closer io.Closer)
type Connection ¶
type Control ¶
type Control struct { Type ControlType CircuitId string Headers channel.Headers }
func UnmarshallControl ¶
func (*Control) CreateTraceResponse ¶
func (*Control) DecrementAndGetHop ¶
func (*Control) GetLoggerFields ¶
func (*Control) IsTypeTraceRoute ¶
func (*Control) IsTypeTraceRouteResponse ¶
type ControlReceiver ¶
type ControlReceiver interface {
HandleControlReceive(controlType ControlType, headers channel.Headers)
}
type ControlType ¶
type ControlType byte
const ( ControlTypeTraceRoute ControlType = 1 ControlTypeTraceRouteResponse ControlType = 2 )
func (ControlType) String ¶
func (self ControlType) String() string
type DialParams ¶
type Factory ¶
type Factory interface { CreateListener(optionsData OptionsData) (Listener, error) CreateDialer(optionsData OptionsData) (Dialer, error) }
type Header ¶
func (*Header) GetCircuitId ¶
func (*Header) GetOriginator ¶
func (header *Header) GetOriginator() Originator
type InvalidTerminatorError ¶
type InvalidTerminatorError struct {
InnerError error
}
func (InvalidTerminatorError) Error ¶
func (e InvalidTerminatorError) Error() string
func (InvalidTerminatorError) Unwrap ¶
func (e InvalidTerminatorError) Unwrap() error
type LinkReceiveBuffer ¶
type LinkReceiveBuffer struct {
// contains filtered or unexported fields
}
func NewLinkReceiveBuffer ¶
func NewLinkReceiveBuffer() *LinkReceiveBuffer
func (*LinkReceiveBuffer) Inspect ¶
func (buffer *LinkReceiveBuffer) Inspect() *inspect.XgressRecvBufferDetail
func (*LinkReceiveBuffer) PeekHead ¶
func (buffer *LinkReceiveBuffer) PeekHead() *Payload
func (*LinkReceiveBuffer) ReceiveUnordered ¶
func (buffer *LinkReceiveBuffer) ReceiveUnordered(payload *Payload, maxSize uint32) bool
func (*LinkReceiveBuffer) Remove ¶
func (buffer *LinkReceiveBuffer) Remove(payload *Payload)
func (*LinkReceiveBuffer) Size ¶
func (buffer *LinkReceiveBuffer) Size() uint32
type LinkSendBuffer ¶
type LinkSendBuffer struct {
// contains filtered or unexported fields
}
Note: if altering this struct, be sure to account for 64 bit alignment on 32 bit arm arch https://pkg.go.dev/sync/atomic#pkg-note-BUG https://github.com/golang/go/issues/36606
func NewLinkSendBuffer ¶
func NewLinkSendBuffer(x *Xgress) *LinkSendBuffer
func (*LinkSendBuffer) BufferPayload ¶
func (buffer *LinkSendBuffer) BufferPayload(payload *Payload) (func(), error)
func (*LinkSendBuffer) Close ¶
func (buffer *LinkSendBuffer) Close()
func (*LinkSendBuffer) CloseWhenEmpty ¶
func (buffer *LinkSendBuffer) CloseWhenEmpty() bool
func (*LinkSendBuffer) Inspect ¶
func (buffer *LinkSendBuffer) Inspect() *inspect.XgressSendBufferDetail
func (*LinkSendBuffer) ReceiveAcknowledgement ¶
func (buffer *LinkSendBuffer) ReceiveAcknowledgement(ack *Acknowledgement)
type Listener ¶
type Listener interface { Listen(address string, bindHandler BindHandler) error Close() error }
type MisconfiguredTerminatorError ¶
type MisconfiguredTerminatorError struct {
InnerError error
}
func (MisconfiguredTerminatorError) Error ¶
func (e MisconfiguredTerminatorError) Error() string
func (MisconfiguredTerminatorError) Unwrap ¶
func (e MisconfiguredTerminatorError) Unwrap() error
type Options ¶
type Options struct { Mtu int32 RandomDrops bool Drop1InN int32 TxQueueSize int32 TxPortalStartSize uint32 TxPortalMaxSize uint32 TxPortalMinSize uint32 TxPortalIncreaseThresh uint32 TxPortalIncreaseScale float64 TxPortalRetxThresh uint32 TxPortalRetxScale float64 TxPortalDupAckThresh uint32 TxPortalDupAckScale float64 RxBufferSize uint32 RetxStartMs uint32 RetxScale float64 RetxAddMs uint32 MaxCloseWait time.Duration GetCircuitTimeout time.Duration CircuitStartTimeout time.Duration ConnectTimeout time.Duration }
Options contains common Xgress configuration options
func DefaultOptions ¶
func DefaultOptions() *Options
func LoadOptions ¶
func LoadOptions(data OptionsData) (*Options, error)
type OptionsData ¶
type OptionsData map[interface{}]interface{}
type Originator ¶
type Originator int32
const ( Initiator Originator = 0 Terminator Originator = 1 )
func (Originator) String ¶
func (o Originator) String() string
type Payload ¶
func UnmarshallPayload ¶
func (*Payload) GetLoggerFields ¶
func (*Payload) GetSequence ¶
func (*Payload) IsCircuitEndFlagSet ¶
func (*Payload) IsCircuitStartFlagSet ¶
type PayloadBufferForwarder ¶
type PayloadFlag ¶
type PayloadFlag uint32
const ( PayloadFlagCircuitEnd PayloadFlag = 1 PayloadFlagOriginator PayloadFlag = 2 PayloadFlagCircuitStart PayloadFlag = 4 )
type PayloadIngester ¶
type PayloadIngester struct {
// contains filtered or unexported fields
}
func NewPayloadIngester ¶
func NewPayloadIngester(closeNotify <-chan struct{}) *PayloadIngester
type PeekHandler ¶
type PeekHandler interface { Rx(x *Xgress, payload *Payload) Tx(x *Xgress, payload *Payload) Close(x *Xgress) }
PeekHandler allows registering watcher to react to data flowing an xgress instance
type ReceiveHandler ¶
type ReceiveHandler interface { // HandleXgressReceive is invoked when data is received from the connected xgress peer. // HandleXgressReceive(payload *Payload, x *Xgress) HandleControlReceive(control *Control, x *Xgress) }
ReceiveHandler is invoked by an xgress whenever data is received from the connected peer. Generally a ReceiveHandler is implemented to connect the xgress to a data plane data transmission system.
type Response ¶
type Response struct { Success bool `json:"scc"` Message string `json:"msg"` CircuitId string `json:"circuitId"` }
func CreateCircuit ¶
func CreateCircuit(ctrl networkControllers, peer Connection, request *Request, bindHandler BindHandler, options *Options) *Response
func ReceiveResponse ¶
func ResponseFromJSON ¶
type Retransmitter ¶
type Retransmitter struct {
// contains filtered or unexported fields
}
func NewRetransmitter ¶
func NewRetransmitter(forwarder PayloadBufferForwarder, faultReporter RetransmitterFaultReporter, metrics metrics.Registry, closeNotify <-chan struct{}) *Retransmitter
type Xgress ¶
type Xgress struct { Options *Options // contains filtered or unexported fields }
func NewXgress ¶
func NewXgress(circuitId string, ctrlId string, address Address, peer Connection, originator Originator, options *Options, tags map[string]string) *Xgress
func (*Xgress) AddCloseHandler ¶
func (self *Xgress) AddCloseHandler(closeHandler CloseHandler)
func (*Xgress) AddPeekHandler ¶
func (self *Xgress) AddPeekHandler(peekHandler PeekHandler)
func (*Xgress) Close ¶
func (self *Xgress) Close()
Things which can trigger close
1. Read fails 2. Write fails 3. End of Circuit received 4. Unroute received
func (*Xgress) CloseTimeout ¶
func (*Xgress) ForwardEndOfCircuit ¶
func (*Xgress) GetEndCircuit ¶
func (*Xgress) GetIntervalId ¶
func (*Xgress) GetSequence ¶
func (*Xgress) GetStartCircuit ¶
func (*Xgress) GetTimeOfLastRxFromLink ¶
func (*Xgress) HandleControlReceive ¶
func (self *Xgress) HandleControlReceive(controlType ControlType, headers channel.Headers)
func (*Xgress) InspectCircuit ¶
func (self *Xgress) InspectCircuit(detail *inspect.CircuitInspectDetail)
func (*Xgress) IsCircuitStarted ¶
func (*Xgress) IsEndOfCircuitReceived ¶
func (*Xgress) IsEndOfCircuitSent ¶
func (*Xgress) IsTerminator ¶
func (*Xgress) Originator ¶
func (self *Xgress) Originator() Originator
func (*Xgress) PayloadReceived ¶
func (*Xgress) SendAcknowledgement ¶
func (self *Xgress) SendAcknowledgement(acknowledgement *Acknowledgement) error
func (*Xgress) SendControl ¶
func (*Xgress) SendEmptyAck ¶
func (self *Xgress) SendEmptyAck()
func (*Xgress) SendPayload ¶
func (*Xgress) SetReceiveHandler ¶
func (self *Xgress) SetReceiveHandler(receiveHandler ReceiveHandler)