xgress

package
v0.14.10 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 26 Imported by: 6

Documentation

Index

Constants

View Source
const (
	MinHeaderKey = 2000
	MaxHeaderKey = MinHeaderKey + int32(math.MaxUint8)

	HeaderKeySessionId = 2256
	HeaderKeySequence  = 2257
	HeaderKeyFlags     = 2258

	ContentTypePayloadType         = 1100
	ContentTypeAcknowledgementType = 1101
)
View Source
const DECODER = "data"
View Source
const (
	HeaderKeyUUID = 0
)

Variables

View Source
var ContentTypeValue = map[string]int32{
	"PayloadType":         ContentTypePayloadType,
	"AcknowledgementType": ContentTypeAcknowledgementType,
}

Functions

func AddTerminator

func AddTerminator(ctrl CtrlChannel, serviceId, binding, address, identity string, identitySecret []byte, peerData map[uint32][]byte, staticCost uint16, precedence ctrl_pb.TerminatorPrecedence) (string, error)

func DecodePayload

func DecodePayload(payload *Payload) ([]byte, bool)

func GlobalRegistry

func GlobalRegistry() *registry

func NewRegistry

func NewRegistry() *registry

func ReadUntil

func ReadUntil(peer transport.Connection, stop byte) ([]byte, error)

func ReadUntilNewline

func ReadUntilNewline(peer transport.Connection) ([]byte, error)

func RemoveTerminator

func RemoveTerminator(ctrl CtrlChannel, terminatorId string) error

func SendRequest

func SendRequest(request *Request, peer io.Writer) error

func SendResponse

func SendResponse(response *Response, peer io.Writer) error

func SetOriginatorFlag

func SetOriginatorFlag(flags uint32, originator Originator) uint32

func UpdateTerminator

func UpdateTerminator(ctrl CtrlChannel, terminatorId string, staticCost *uint16, precedence *ctrl_pb.TerminatorPrecedence) error

Types

type Acknowledgement

type Acknowledgement struct {
	Header
	Sequence []int32
}

func NewAcknowledgement

func NewAcknowledgement(sessionId string, originator Originator) *Acknowledgement

func UnmarshallAcknowledgement

func UnmarshallAcknowledgement(msg *channel2.Message) (*Acknowledgement, error)

func (*Acknowledgement) GetSequence

func (ack *Acknowledgement) GetSequence() []int32

func (*Acknowledgement) Marshall

func (ack *Acknowledgement) Marshall() *channel2.Message

type Address

type Address string

type BindHandler

type BindHandler interface {
	HandleXgressBind(sessionId *identity.TokenId, address Address, originator Originator, x *Xgress)
}

The BindHandlers are invoked to install the appropriate handlers.

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 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 Connection interface {
	io.Closer
	LogContext() string
	ReadPayload() ([]byte, map[uint8][]byte, error)
	WritePayload([]byte, map[uint8][]byte) (int, error)
}

type CtrlChannel

type CtrlChannel interface {
	Channel() channel2.Channel
}

type Decoder

type Decoder struct{}

func (Decoder) Decode

func (d Decoder) Decode(msg *channel2.Message) ([]byte, bool)

type Dialer

type Dialer interface {
	Dial(destination string, sessionId *identity.TokenId, address Address, bindHandler BindHandler) (xt.PeerData, error)
	IsTerminatorValid(id string, destination string) bool
}

type Factory

type Factory interface {
	CreateListener(optionsData OptionsData) (Listener, error)
	CreateDialer(optionsData OptionsData) (Dialer, error)
}
type Header struct {
	SessionId string
	Flags     uint32
}

func (*Header) GetFlags

func (header *Header) GetFlags() string

func (*Header) GetOriginator

func (header *Header) GetOriginator() Originator

func (*Header) GetSessionId

func (header *Header) GetSessionId() string

type Listener

type Listener interface {
	Listen(address string, bindHandler BindHandler) error
	Close() error
}

type Options

type Options struct {
	Mtu            int32
	Retransmission bool
	RandomDrops    bool
	Drop1InN       int32
}

Options contains common Xgress configuration options

func DefaultOptions

func DefaultOptions() *Options

func LoadOptions

func LoadOptions(data OptionsData) *Options

func (Options) String

func (options Options) String() string

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

type Payload struct {
	Header
	Sequence int32
	Headers  map[uint8][]byte
	Data     []byte
}

func UnmarshallPayload

func UnmarshallPayload(msg *channel2.Message) (*Payload, error)

func (*Payload) GetLoggerFields

func (payload *Payload) GetLoggerFields() logrus.Fields

func (*Payload) GetSequence

func (payload *Payload) GetSequence() int32

func (*Payload) IsSessionEndFlagSet

func (payload *Payload) IsSessionEndFlagSet() bool

func (*Payload) IsSessionStartFlagSet added in v0.12.0

func (payload *Payload) IsSessionStartFlagSet() bool

func (*Payload) Marshall

func (payload *Payload) Marshall() *channel2.Message

type PayloadBuffer

type PayloadBuffer struct {
	SrcAddress Address
	Originator Originator
	// contains filtered or unexported fields
}

func NewPayloadBuffer

func NewPayloadBuffer(sessionId *identity.TokenId, forwarder PayloadBufferForwarder) *PayloadBuffer

func (*PayloadBuffer) AcknowledgePayload

func (buffer *PayloadBuffer) AcknowledgePayload(payload *Payload)

func (*PayloadBuffer) BufferPayload

func (buffer *PayloadBuffer) BufferPayload(payload *Payload)

func (*PayloadBuffer) Close

func (buffer *PayloadBuffer) Close()

func (*PayloadBuffer) ReceiveAcknowledgement

func (buffer *PayloadBuffer) ReceiveAcknowledgement(ack *Acknowledgement)

type PayloadBufferController

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

func NewPayloadBufferController

func NewPayloadBufferController(forwarder PayloadBufferForwarder) *PayloadBufferController

func (*PayloadBufferController) BufferForSession

func (controller *PayloadBufferController) BufferForSession(sessionId *identity.TokenId, address Address) *PayloadBuffer

func (*PayloadBufferController) EndSession

func (controller *PayloadBufferController) EndSession(sessionId *identity.TokenId)

type PayloadBufferForwarder

type PayloadBufferForwarder interface {
	ForwardPayload(srcAddr Address, payload *Payload) error
	ForwardAcknowledgement(srcAddr Address, acknowledgement *Acknowledgement) error
}

type PayloadFlag

type PayloadFlag uint32
const (
	PayloadFlagSessionEnd   PayloadFlag = 1
	PayloadFlagEgress       PayloadFlag = 2
	PayloadFlagSessionStart PayloadFlag = 4
)

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)
}

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 Request

type Request struct {
	Id        string `json:"id"`
	ServiceId string `json:"svcId"`
}

func ReceiveRequest

func ReceiveRequest(peer transport.Connection) (*Request, error)

func RequestFromJSON

func RequestFromJSON(payload []byte) (*Request, error)

func (*Request) ToJSON

func (r *Request) ToJSON() ([]byte, error)

type Response

type Response struct {
	Success   bool   `json:"scc"`
	Message   string `json:"msg"`
	SessionId string `json:"sessionId"`
}

func CreateSession

func CreateSession(ctrl CtrlChannel, peer Connection, request *Request, bindHandler BindHandler, options *Options) *Response

func ReceiveResponse

func ReceiveResponse(peer transport.Connection) (*Response, error)

func ResponseFromJSON

func ResponseFromJSON(payload []byte) (*Response, error)

func (*Response) ToJSON

func (r *Response) ToJSON() ([]byte, error)

type SessionInfo

type SessionInfo struct {
	SessionId   *identity.TokenId
	Address     Address
	ResponseMsg *channel2.Message
	// contains filtered or unexported fields
}

func GetSession

func GetSession(ctrl CtrlChannel, ingressId string, serviceId string, peerData map[uint32][]byte) (*SessionInfo, error)

type TransmitBuffer

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

func NewTransmitBuffer

func NewTransmitBuffer() *TransmitBuffer

func (*TransmitBuffer) ReadyForTransmit

func (buffer *TransmitBuffer) ReadyForTransmit() []*Payload

func (*TransmitBuffer) ReceiveUnordered

func (buffer *TransmitBuffer) ReceiveUnordered(payload *Payload)

type Xgress

type Xgress struct {
	Options *Options
	// contains filtered or unexported fields
}

func NewXgress

func NewXgress(sessionId *identity.TokenId, address Address, peer Connection, originator Originator, options *Options) *Xgress

func (*Xgress) AddPeekHandler

func (self *Xgress) AddPeekHandler(peekHandler PeekHandler)

func (*Xgress) Address

func (self *Xgress) Address() Address

func (*Xgress) Close

func (self *Xgress) Close()

func (*Xgress) CloseTimeout

func (self *Xgress) CloseTimeout(duration time.Duration)

func (*Xgress) Closed

func (self *Xgress) Closed() bool

func (*Xgress) GetEndSession

func (self *Xgress) GetEndSession() *Payload

func (*Xgress) GetStartSession added in v0.12.0

func (self *Xgress) GetStartSession() *Payload

func (*Xgress) IsTerminator

func (self *Xgress) IsTerminator() bool

func (*Xgress) Label

func (self *Xgress) Label() string

func (*Xgress) Originator

func (self *Xgress) Originator() Originator

func (*Xgress) SendAcknowledgement

func (self *Xgress) SendAcknowledgement(acknowledgement *Acknowledgement) error

func (*Xgress) SendPayload

func (self *Xgress) SendPayload(payload *Payload) error

func (*Xgress) SessionId

func (self *Xgress) SessionId() *identity.TokenId

func (*Xgress) SetCloseHandler

func (self *Xgress) SetCloseHandler(closeHandler CloseHandler)

func (*Xgress) SetPayloadBuffer

func (self *Xgress) SetPayloadBuffer(payloadBuffer *PayloadBuffer)

func (*Xgress) SetReceiveHandler

func (self *Xgress) SetReceiveHandler(receiveHandler ReceiveHandler)

func (*Xgress) Start

func (self *Xgress) Start()

Jump to

Keyboard shortcuts

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