-
Notifications
You must be signed in to change notification settings - Fork 10
/
transport.go
42 lines (34 loc) · 1.23 KB
/
transport.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package transport
import (
"context"
"github.com/aperturerobotics/bifrost/link"
"github.com/aperturerobotics/bifrost/peer"
"github.com/aperturerobotics/controllerbus/controller"
)
// Transport is similar to a NIC, yielding links to remote peers.
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
}
// TransportHandler manages a Transport and receives event callbacks.
// This is typically fulfilled by the transport controller.
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)
}
// Controller is a transport 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)
}