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) 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, lnk link.Link, strm stream.Stream, ...)
- func (c *Controller) HandleLinkEstablished(lnk link.Link)
- func (c *Controller) HandleLinkLost(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, 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 (*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, 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.
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