transport_controller

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var File_github_com_aperturerobotics_bifrost_transport_controller_controller_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Constructor

type Constructor func(
	ctx context.Context,
	le *logrus.Entry,
	pkey crypto.PrivKey,
	handler transport.TransportHandler,
) (transport.Transport, error)

Constructor constructs a transport with common parameters.

type Controller

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

Controller implements a common transport controller. The controller looks up the Node, acquires its identity, constructs the transport, and manages the lifecycle of dialing and accepting links.

func NewController

func NewController(
	le *logrus.Entry,
	bus bus.Bus,
	info *controller.Info,
	peerID peer.ID,
	ctor Constructor,
) *Controller

NewController constructs a new transport controller.

func (*Controller) Close

func (c *Controller) Close() error

Close releases any resources used by the controller. Error indicates any issue encountered releasing.

func (*Controller) Execute

func (c *Controller) Execute(ctx context.Context) error

Execute executes the transport controller and the transport. Returning nil ends execution. Returning an error triggers a retry with backoff.

func (*Controller) GetControllerID

func (c *Controller) GetControllerID() string

GetControllerID returns the controller ID.

func (*Controller) GetControllerInfo

func (c *Controller) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (c *Controller) GetPeerLinks(peerID peer.ID) []link.Link

GetPeerLinks returns all links with the peer.

func (*Controller) GetTransport

func (c *Controller) GetTransport(ctx context.Context) (transport.Transport, error)

GetTransport returns the controlled transport. This may be nil until the transport is constructed.

func (*Controller) HandleDirective

func (c *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive. If it can, it returns a resolver. If not, returns nil. Any exceptional errors are returned for logging. It is safe to add a reference to the directive during this call.

func (*Controller) HandleIncomingStream

func (c *Controller) HandleIncomingStream(
	rctx context.Context,
	lnk link.Link,
	strm stream.Stream,
	strmOpts stream.OpenOpts,
)

HandleIncomingStream handles an incoming stream from a link. It negotiates the protocol for the stream, acquires a handler for the protocol, and hands the stream to the protocol handler, then returns.

rctx is the link Context, which is canceled when the link is closed.

func (*Controller) HandleLinkEstablished

func (c *Controller) HandleLinkEstablished(lnk link.Link)

HandleLinkEstablished is called by the transport when a link is established.

func (*Controller) HandleLinkLost

func (c *Controller) HandleLinkLost(lnk link.Link)

HandleLinkLost is called when a link is lost.

func (*Controller) PushDialer

func (c *Controller) PushDialer(
	ctx context.Context,
	peerID peer.ID,
	opts *dialer.DialerOpts,
) error

PushDialer pushes a new dialer. Waits for the transport to be constructed. If the transport is not a TransportDialer, returns nil. Returns after the dialer is pushed.

type ResolvePeerDialer added in v0.21.0

type ResolvePeerDialer func(
	ctx context.Context,
	le *logrus.Entry,
	pkey crypto.PrivKey,
	peerID peer.ID,
) (*dialer.DialerOpts, error)

ResolvePeerDialer is a function to resolve an address for a peer. Called when resolving EstablishLink. Return nil, nil to indicate not found or unavailable.

func NewResolvePeerDialerWithStaticPeerMap added in v0.21.0

func NewResolvePeerDialerWithStaticPeerMap(spm map[string]*dialer.DialerOpts) ResolvePeerDialer

NewResolvePeerDialerWithStaticPeerMap builds a new ResolvePeerDialer from a peer map.

type StreamEstablish

type StreamEstablish struct {

	// ProtocolID is the protocol identifier string for the stream.
	ProtocolId string `protobuf:"bytes,1,opt,name=protocol_id,json=protocolId,proto3" json:"protocol_id,omitempty"`
	// contains filtered or unexported fields
}

StreamEstablish is the first message sent by the initiator of a stream. Prefixed by a uint32 length. Max size: 100kb

func NewStreamEstablish

func NewStreamEstablish(protocolID protocol.ID) *StreamEstablish

NewStreamEstablish constructs a new StreamEstablish message.

func (*StreamEstablish) CloneMessageVT added in v0.15.6

func (m *StreamEstablish) CloneMessageVT() proto.Message

func (*StreamEstablish) CloneVT added in v0.8.3

func (m *StreamEstablish) CloneVT() *StreamEstablish

func (*StreamEstablish) Descriptor deprecated

func (*StreamEstablish) Descriptor() ([]byte, []int)

Deprecated: Use StreamEstablish.ProtoReflect.Descriptor instead.

func (*StreamEstablish) EqualMessageVT added in v0.15.6

func (this *StreamEstablish) EqualMessageVT(thatMsg proto.Message) bool

func (*StreamEstablish) EqualVT added in v0.3.0

func (this *StreamEstablish) EqualVT(that *StreamEstablish) bool

func (*StreamEstablish) GetProtocolId

func (x *StreamEstablish) GetProtocolId() string

func (*StreamEstablish) MarshalToSizedBufferVT added in v0.2.0

func (m *StreamEstablish) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*StreamEstablish) MarshalToVT added in v0.2.0

func (m *StreamEstablish) MarshalToVT(dAtA []byte) (int, error)

func (*StreamEstablish) MarshalVT added in v0.2.0

func (m *StreamEstablish) MarshalVT() (dAtA []byte, err error)

func (*StreamEstablish) ProtoMessage

func (*StreamEstablish) ProtoMessage()

func (*StreamEstablish) ProtoReflect added in v0.2.0

func (x *StreamEstablish) ProtoReflect() protoreflect.Message

func (*StreamEstablish) Reset

func (x *StreamEstablish) Reset()

func (*StreamEstablish) SizeVT added in v0.2.0

func (m *StreamEstablish) SizeVT() (n int)

func (*StreamEstablish) String

func (x *StreamEstablish) String() string

func (*StreamEstablish) UnmarshalVT added in v0.2.0

func (m *StreamEstablish) UnmarshalVT(dAtA []byte) error

Jump to

Keyboard shortcuts

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