Documentation
¶
Index ¶
- type Constructor
- type Controller
- func (c *Controller) Close() error
- func (c *Controller) DialPeerAddr(ctx context.Context, peerID peer.ID, opts *dialer.DialerOpts) (link.Link, error)
- func (c *Controller) Execute(ctx context.Context) error
- func (c *Controller) GetControllerID() string
- func (c *Controller) GetControllerInfo() *controller.Info
- func (c *Controller) GetLinkedPeerIDsSnapshotWithWait(peerIDs []peer.ID) (map[peer.ID]struct{}, <-chan struct{})
- func (c *Controller) GetPeerLinks(peerID peer.ID) []link.Link
- func (c *Controller) GetTransport(ctx context.Context) (transport.Transport, error)
- func (c *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)
- func (c *Controller) HandleIncomingStream(rctx context.Context, tpt transport.Transport, lnk link.Link, ...)
- type ResolvePeerDialer
- type StreamEstablish
- func (m *StreamEstablish) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *StreamEstablish) CloneVT() *StreamEstablish
- func (this *StreamEstablish) EqualMessageVT(thatMsg any) bool
- func (this *StreamEstablish) EqualVT(that *StreamEstablish) bool
- func (x *StreamEstablish) GetProtocolId() string
- func (x *StreamEstablish) MarshalJSON() ([]byte, error)
- func (x *StreamEstablish) MarshalProtoJSON(s *json.MarshalState)
- func (x *StreamEstablish) MarshalProtoText() string
- func (m *StreamEstablish) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *StreamEstablish) MarshalToVT(dAtA []byte) (int, error)
- func (m *StreamEstablish) MarshalVT() (dAtA []byte, err error)
- func (*StreamEstablish) ProtoMessage()
- func (x *StreamEstablish) Reset()
- func (m *StreamEstablish) SizeVT() (n int)
- func (x *StreamEstablish) String() string
- func (x *StreamEstablish) UnmarshalJSON(b []byte) error
- func (x *StreamEstablish) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *StreamEstablish) UnmarshalVT(dAtA []byte) error
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 ¶
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 (*Controller) GetLinkedPeerIDsSnapshotWithWait ¶ added in v0.51.7
func (c *Controller) GetLinkedPeerIDsSnapshotWithWait(peerIDs []peer.ID) (map[peer.ID]struct{}, <-chan struct{})
GetLinkedPeerIDsSnapshotWithWait returns linked peer IDs and a wait channel that closes when the transport link set changes.
func (*Controller) GetPeerLinks ¶
func (c *Controller) GetPeerLinks(peerID peer.ID) []link.Link
GetPeerLinks returns all links with the peer.
func (*Controller) GetTransport ¶
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 ¶
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 ¶
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 ¶
func (m *StreamEstablish) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*StreamEstablish) CloneVT ¶
func (m *StreamEstablish) CloneVT() *StreamEstablish
func (*StreamEstablish) EqualMessageVT ¶
func (this *StreamEstablish) EqualMessageVT(thatMsg any) bool
func (*StreamEstablish) EqualVT ¶
func (this *StreamEstablish) EqualVT(that *StreamEstablish) bool
func (*StreamEstablish) GetProtocolId ¶
func (x *StreamEstablish) GetProtocolId() string
func (*StreamEstablish) MarshalJSON ¶
func (x *StreamEstablish) MarshalJSON() ([]byte, error)
MarshalJSON marshals the StreamEstablish to JSON.
func (*StreamEstablish) MarshalProtoJSON ¶
func (x *StreamEstablish) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the StreamEstablish message to JSON.
func (*StreamEstablish) MarshalProtoText ¶
func (x *StreamEstablish) MarshalProtoText() string
func (*StreamEstablish) MarshalToSizedBufferVT ¶
func (m *StreamEstablish) MarshalToSizedBufferVT(dAtA []byte) (int, error)
func (*StreamEstablish) MarshalToVT ¶
func (m *StreamEstablish) MarshalToVT(dAtA []byte) (int, error)
func (*StreamEstablish) MarshalVT ¶
func (m *StreamEstablish) MarshalVT() (dAtA []byte, err error)
func (*StreamEstablish) ProtoMessage ¶
func (*StreamEstablish) ProtoMessage()
func (*StreamEstablish) Reset ¶
func (x *StreamEstablish) Reset()
func (*StreamEstablish) SizeVT ¶
func (m *StreamEstablish) SizeVT() (n int)
func (*StreamEstablish) String ¶
func (x *StreamEstablish) String() string
func (*StreamEstablish) UnmarshalJSON ¶
func (x *StreamEstablish) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the StreamEstablish from JSON.
func (*StreamEstablish) UnmarshalProtoJSON ¶
func (x *StreamEstablish) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the StreamEstablish message from JSON.
func (*StreamEstablish) UnmarshalVT ¶
func (m *StreamEstablish) UnmarshalVT(dAtA []byte) error