Documentation ¶
Overview ¶
Package transport defines the interfaces needed for various mesh operations.
Index ¶
- Variables
- func IsSignalTransportClosed(err error) bool
- type BootstrapTransport
- type BootstrapTransportFunc
- type Dialer
- type FeatureResolver
- type FeatureResolverFunc
- type JoinRoundTripper
- type JoinRoundTripperFunc
- type JoinServer
- type JoinServerFunc
- type LeaderDialer
- type LeaderDialerFunc
- type LeaveRoundTripper
- type LeaveRoundTripperFunc
- type NodeDialer
- type NodeDialerFunc
- type NodeIDResolver
- type NodeIDResolverFunc
- type RPCClientConn
- type RPCTransport
- type RaftTransport
- type Resolver
- type ResolverFunc
- type RoundTripper
- type RoundTripperFunc
- type UnaryServer
- type UnaryServerFunc
- type WebRTCSignalTransport
Constants ¶
This section is empty.
Variables ¶
var ErrSignalTransportClosed = fmt.Errorf("signal transport closed")
ErrSignalTransportClosed is returned when a signal transport is closed by either side of the connection.
Functions ¶
func IsSignalTransportClosed ¶
IsSignalTransportClosed returns true if the given error is ErrSignalTransportClosed.
Types ¶
type BootstrapTransport ¶
type BootstrapTransport interface { // LeaderElect should perform an initial leader election. It returns // true is this node was elected leader, or otherwise a JoinRoundTripper // for contacting the elected leader. If one or more nodes believe // the cluster to be already bootstrapped, then storage.ErrAlreadyBootstrapped // should be returned with an optional JoinRoundTripper to nodes who are // already bootstrapped. LeaderElect(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error) }
BootstrapTransport is the interface for dialing other peers to bootstrap a new mesh.
func NewNullBootstrapTransport ¶
func NewNullBootstrapTransport() BootstrapTransport
NewNullBootstrapTransport returns a BootstrapTransport that always returns true for LeaderElect and nil for JoinRoundTripper. This is useful for testing or when otherwise no bootstrap transport is needed.
type BootstrapTransportFunc ¶
type BootstrapTransportFunc func(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error)
BootstrapTransportFunc is a function that implements BootstrapTransport.
func (BootstrapTransportFunc) LeaderElect ¶
func (f BootstrapTransportFunc) LeaderElect(ctx context.Context) (isLeader bool, rt JoinRoundTripper, err error)
LeaderElect implements BootstrapTransport.
type Dialer ¶
Dialer is a generic interface for dialing a target address over the given network. It resembles the net.Dialer interface.
type FeatureResolver ¶
FeatureResolver is a resolver that resolves node addresses by feature.
type FeatureResolverFunc ¶
type FeatureResolverFunc = ResolverFunc[v1.Feature]
FeatureResolverFunc is a function that implements FeatureResolver.
type JoinRoundTripper ¶
type JoinRoundTripper = RoundTripper[v1.JoinRequest, v1.JoinResponse]
JoinRoundTripper is the interface for joining a cluster.
type JoinRoundTripperFunc ¶
type JoinRoundTripperFunc = RoundTripperFunc[v1.JoinRequest, v1.JoinResponse]
JoinRoundTripperFunc is a function that implements JoinRoundTripper.
type JoinServer ¶
type JoinServer = UnaryServer[v1.JoinRequest, v1.JoinResponse]
JoinServer is the interface for handling requests to join a cluster.
type JoinServerFunc ¶
type JoinServerFunc = UnaryServerFunc[v1.JoinRequest, v1.JoinResponse]
JoinServerFunc is a function that implements JoinServer.
type LeaderDialer ¶
type LeaderDialer interface { // DialLeader opens a gRPC connection to the current leader. DialLeader(ctx context.Context) (RPCClientConn, error) }
LeaderDialer is the interface for dialing the current leader.
func NewNoOpLeaderDialer ¶ added in v0.10.5
func NewNoOpLeaderDialer() LeaderDialer
NewNoOpLeaderDialer returns a dialer that always returns an error.
type LeaderDialerFunc ¶
type LeaderDialerFunc func(ctx context.Context) (RPCClientConn, error)
LeaderDialerFunc is a function that implements LeaderDialer.
func (LeaderDialerFunc) DialLeader ¶
func (f LeaderDialerFunc) DialLeader(ctx context.Context) (RPCClientConn, error)
DialLeader implements LeaderDialer.
type LeaveRoundTripper ¶ added in v0.11.2
type LeaveRoundTripper = RoundTripper[v1.LeaveRequest, v1.LeaveResponse]
LeaveRoundTripper is the interface for leaving a cluster.
type LeaveRoundTripperFunc ¶ added in v0.11.2
type LeaveRoundTripperFunc = RoundTripperFunc[v1.LeaveRequest, v1.LeaveResponse]
LeaveRoundTripperFunc is a function that implements LeaveRoundTripper.
type NodeDialer ¶
NodeDialer is an interface for dialing an arbitrary node. The node ID is optional and if empty, implementations can choose the node to dial.
func NewNoOpNodeDialer ¶ added in v0.10.5
func NewNoOpNodeDialer() NodeDialer
NewNoOpNodeDialer returns a dialer that always returns an error.
type NodeDialerFunc ¶
NodeDialerFunc is the function signature for dialing an arbitrary node. It is supplied by the mesh during startup. It can be used as an alternative to the NodeDialer interface.
func (NodeDialerFunc) DialNode ¶
func (f NodeDialerFunc) DialNode(ctx context.Context, id types.NodeID) (RPCClientConn, error)
Dial implements NodeDialer.
type NodeIDResolver ¶
NodeIDResolver is a resolver that resolves node addresses by node ID.
type NodeIDResolverFunc ¶
type NodeIDResolverFunc = ResolverFunc[types.NodeID]
NodeIDResolverFunc is a function that implements NodeIDResolver.
type RPCClientConn ¶ added in v0.15.8
type RPCClientConn interface { grpc.ClientConnInterface io.Closer }
RPCClientConn is a grpc.ClientConnInterface that can be closed.
type RPCTransport ¶ added in v0.15.0
type RPCTransport interface { // Dial opens a gRPC client connection to the remote address. Implementations // may choose to ignore the id or address. Dial(ctx context.Context, id, address string) (RPCClientConn, error) }
RPCTransport is the interface for opening a gRPC connection to a remote peer. the ID is optional and may be ignored by implementations.
type RaftTransport ¶
type RaftTransport interface { raft.Transport LeaderDialer // AddrPort returns the address and port the transport is listening on. AddrPort() netip.AddrPort // Close closes the transport. Close() error }
RaftTransport defines the methods needed for raft consensus to function in a webmesh cluster.
type Resolver ¶
type Resolver[T any] interface { // Resolve resolves the addresses for the given lookup parameters. Resolve(ctx context.Context, lookup T) ([]netip.AddrPort, error) }
Resolver is the interface for resolving node addresses. Implementations can be pre-baked for specialized cases, such as resolving node addresses by a specific feature. The returned type is an AddrPort to support resolvers that need to return port numbers.
func NewNoopResolver ¶ added in v0.10.5
NewNoopResolver returns a no-op resolver of the specified type.
type ResolverFunc ¶
ResolverFunc is a function that implements Resolver.
type RoundTripper ¶
type RoundTripper[REQ, RESP any] interface { io.Closer RoundTrip(ctx context.Context, req *REQ) (*RESP, error) }
RoundTripper is a generic interface for executing a request and returning a response.
type RoundTripperFunc ¶
RoundTripperFunc is a function that implements RoundTripper.
func (RoundTripperFunc[REQ, RESP]) Close ¶
func (f RoundTripperFunc[REQ, RESP]) Close() error
RoundTrip implements RoundTripper.
type UnaryServer ¶
type UnaryServer[REQ, RESP any] interface { // Serve is executed when a unary request is received. Serve(ctx context.Context, req *REQ) (*RESP, error) }
UnaryServer is the interface for handling unary requests.
type UnaryServerFunc ¶
UnaryServerFunc is a function that implements UnaryServer.
type WebRTCSignalTransport ¶
type WebRTCSignalTransport interface { // Start starts the transport. This will not return until a remote peer // has provided a session description. Start(ctx context.Context) error // TURNServers returns a list of TURN servers configured for the transport. TURNServers() []webrtc.ICEServer // SendDescription sends an SDP description to the remote peer. SendDescription(ctx context.Context, desc webrtc.SessionDescription) error // SendCandidate sends an ICE candidate to the remote peer. SendCandidate(ctx context.Context, candidate webrtc.ICECandidateInit) error // Candidates returns a channel of ICE candidates received from the remote peer. Candidates() <-chan webrtc.ICECandidateInit // RemoteDescription returns the SDP description received from the remote peer. RemoteDescription() webrtc.SessionDescription // Error returns a channel that receives any error encountered during signaling. // This channel will be closed when the transport is closed. Error() <-chan error // Close closes the transport. Close() error }
WebRTCSignalTransport is the transport interface for providing WebRTC signaling between mesh nodes.
Directories ¶
Path | Synopsis |
---|---|
Package datachannels provides a WebRTC data channel API for port forwarding.
|
Package datachannels provides a WebRTC data channel API for port forwarding. |
Package libp2p provides webmesh integration with libp2p.
|
Package libp2p provides webmesh integration with libp2p. |
embedded/protocol
Package protocol defines the libp2p webmesh protocol.
|
Package protocol defines the libp2p webmesh protocol. |
embedded/transport
Package transport defines the libp2p webmesh transport.
|
Package transport defines the libp2p webmesh transport. |
embedded/util
Package util provides utility functions for the webmesh libp2p integrations.
|
Package util provides utility functions for the webmesh libp2p integrations. |
embedded/wgtransport
Package wgtransport implements a Webmesh WireGuard transport for libp2p.
|
Package wgtransport implements a Webmesh WireGuard transport for libp2p. |
Package tcp provides TCP based transports.
|
Package tcp provides TCP based transports. |
Package webrtc contains transports for WebRTC.
|
Package webrtc contains transports for WebRTC. |