transport

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// Config indicates this is a controllerbus config.
	config.Config
	// Debuggable indicates this config is debuggable.
	config.Debuggable
	// GetTransportPeerId returns the node peer ID constraint.
	GetTransportPeerId() string
	// SetTransportPeerId sets the node peer ID field.
	SetTransportPeerId(peerID string)
}

Config contains common parameters all transport configs must have.

type Controller

type Controller interface {
	// Controller is the controllerbus controller interface.
	controller.Controller

	// GetTransport returns the controlled transport.
	// This may wait for the controller to be ready.
	GetTransport(ctx context.Context) (Transport, error)
}

Controller is a transport controller.

type LookupTransport

type LookupTransport interface {
	// Directive indicates LookupTransport is a directive.
	directive.Directive

	// LookupTransportPeerIDConstraint returns a specific node ID we are looking for.
	// Can be empty.
	LookupTransportPeerIDConstraint() peer.ID
	// LookupTransportIDConstraint returns a specific transport ID we are looking for.
	// Can be empty.
	LookupTransportIDConstraint() uint64
}

LookupTransport is a directive to lookup running transports. Value type: transport.Transport.

func NewLookupTransport

func NewLookupTransport(peerID peer.ID, transportID uint64) LookupTransport

NewLookupTransport constructs a new LookupTransport directive.

type Transport

type Transport interface {
	// Execute executes the transport as configured, returning any fatal error.
	Execute(ctx context.Context) error
	// GetUUID returns a host-unique ID for this transport.
	GetUUID() uint64
	// GetPeerID returns the peer ID.
	GetPeerID() peer.ID
	// Close closes the transport, returning any errors closing.
	Close() error
}

Transport is similar to a NIC, yielding links to remote peers.

type TransportDialer

type TransportDialer interface {
	// DialPeer dials a peer given an address. The yielded link should be
	// emitted to the transport handler. DialPeer should return nil if the link
	// was established. DialPeer will then not be called again for the same peer
	// ID and address tuple until the yielded link is lost.
	// Returns fatal and error.
	DialPeer(
		ctx context.Context,
		peerID peer.ID,
		addr string,
	) (fatal bool, err error)
}

TransportDialer is a transport that supports dialing string-serialized remote addresses. The Transport controller will call Dial if provided an address for the transport, and directed to connect to the peer.

type TransportHandler

type TransportHandler interface {
	// HandleLinkEstablished is called when a link is established.
	HandleLinkEstablished(lnk link.Link)
	// HandleLinkLost is called when a link is lost.
	HandleLinkLost(lnk link.Link)
}

TransportHandler manages a Transport and receives event callbacks. This is typically fulfilled by the transport controller.

Directories

Path Synopsis
common
kcp

Jump to

Keyboard shortcuts

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