transport_controller

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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.

func NewController

func NewController(
	le *logrus.Entry,
	bus bus.Bus,
	info *controller.Info,
	peerID peer.ID,
	verbose bool,
	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) DialPeerAddr added in v0.36.3

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

DialPeerAddr pushes a new dialer dialing a peer at an address. Waits for the transport to be constructed. Waits for the link to be established and returns the link. If the transport is not a TransportDialer, returns ErrNotTransportDialer.

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 unexpected 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,
	tpt transport.Transport,
	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.

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:"protocolId,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() protobuf_go_lite.CloneMessage

func (*StreamEstablish) CloneVT added in v0.8.3

func (m *StreamEstablish) CloneVT() *StreamEstablish

func (*StreamEstablish) EqualMessageVT added in v0.15.6

func (this *StreamEstablish) EqualMessageVT(thatMsg any) 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) MarshalJSON added in v0.29.0

func (x *StreamEstablish) MarshalJSON() ([]byte, error)

MarshalJSON marshals the StreamEstablish to JSON.

func (*StreamEstablish) MarshalProtoJSON added in v0.29.0

func (x *StreamEstablish) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the StreamEstablish message to JSON.

func (*StreamEstablish) MarshalProtoText added in v0.29.2

func (x *StreamEstablish) MarshalProtoText() 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) 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) UnmarshalJSON added in v0.29.0

func (x *StreamEstablish) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the StreamEstablish from JSON.

func (*StreamEstablish) UnmarshalProtoJSON added in v0.29.0

func (x *StreamEstablish) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the StreamEstablish message from JSON.

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