-
Notifications
You must be signed in to change notification settings - Fork 8
/
link.go
32 lines (30 loc) · 1.2 KB
/
link.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
package link
import (
"github.com/aperturerobotics/bifrost/peer"
"github.com/aperturerobotics/bifrost/stream"
)
// Link represents a one-hop connection between two peers.
type Link interface {
// GetUUID returns the host-unique ID.
// This should be repeatable between re-constructions of the same link.
GetUUID() uint64
// GetTransportUUID returns the unique ID of the transport.
GetTransportUUID() uint64
// OpenStream opens a stream on the link, with the given parameters.
OpenStream(opts stream.OpenOpts) (stream.Stream, error)
// AcceptStream accepts a stream from the link.
// Terminates when the link closes.
AcceptStream() (stream.Stream, stream.OpenOpts, error)
// GetRemotePeer returns the identity of the remote peer.
GetRemotePeer() peer.ID
// GetLocalPeer returns the identity of the local peer.
GetLocalPeer() peer.ID
// GetRemoteTransportUUID returns the reported remote transport UUID.
// This should be negotiated in the handshake.
GetRemoteTransportUUID() uint64
// Close closes the link.
// Any blocked ReadFrom or WriteTo operations will be unblocked and return errors.
// The link should call the HandleLinkLost callback exactly once.
// Close may be called many times.
Close() error
}