Documentation
¶
Index ¶
- Constants
- Variables
- func Connect(ctx context.Context, dst, src net.Conn) <-chan error
- func IsTimeout(err error) bool
- func RegisterConstructor(p protocol.Protocol, c Constructor)
- func RegisterDialer(p protocol.Protocol, d DialFunc)
- type Channel
- type Config
- type Constructor
- type DialFunc
- type Link
- type LinkConnection
- type Peer
Constants ¶
View Source
const (
// LinkSize is the encoded buffer size of Link for wire format
LinkSize = 18
)
Variables ¶
View Source
var (
ErrDestinationNotFound = fmt.Errorf("destination not found among peers")
)
View Source
var MessagingLink = Link{}
MessagingLink defines Link in which implementation should consider as Messaing channel
Functions ¶
func RegisterConstructor ¶ added in v0.5.0
func RegisterConstructor(p protocol.Protocol, c Constructor)
func RegisterDialer ¶ added in v0.5.0
Types ¶
type Channel ¶ added in v0.2.0
type Channel struct {
// contains filtered or unexported fields
}
Channel is a helper struct to coordinate the sending and closing of a channel between different goroutines to avoid data race
func NewChannel ¶ added in v0.2.0
func NewChannel() *Channel
func (*Channel) Incoming ¶ added in v0.2.0
func (c *Channel) Incoming() <-chan LinkConnection
func (*Channel) Put ¶ added in v0.2.0
func (c *Channel) Put(l LinkConnection)
type Config ¶
type Constructor ¶
type DialFunc ¶ added in v0.5.0
type DialFunc func(addr string, c *tls.Config) (connector interface{}, handshake net.Conn, closer func(), err error)
DialFunc is the function signature to help with establishing session with the peer. handshake will be used to negotiate on applcation layer. Connector should be passed to Config.Conn in Peer's constructor.
type Link ¶
type Link struct { Source uint64 Destination uint64 Protocol protocol.Protocol // used for initial multiplexer handshake only ALPN alpn.ALPN // used to specify the expected application protocol }
Link defines a bidirectional source and target. It can be used for negotiations on protocol during initial handshake
func (*Link) MarshalBinary ¶ added in v0.5.1
func (Link) MarshalLogObject ¶ added in v0.5.0
func (l Link) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Link) UnmarshalBinary ¶ added in v0.5.1
type LinkConnection ¶
LinkConnection contains the net.Conn associated with the Link
type Peer ¶
type Peer interface { // Start will accept incoming connections from another Peer Start(context.Context) // Null should disconnect the incoming Peer if an incoming connection is accepted Null(context.Context) // Addr should return the Peer's net.Addr Addr() net.Addr // Initiator should return if the Peer initiated the connection Initiator() bool // Protocol returns the multiplexer protocol in used with the peer Protocol() protocol.Protocol // Peer returns the uint64 identifier of the connected Peer Peer() uint64 // Messaging opens a dedicated bidirectional stream to handle in-band control messages Messaging(context.Context) (net.Conn, error) // Bidirectional establishs a virtual link between the Source and Destination via this Peer Bidirectional(context.Context, net.Conn, Link) (<-chan error, error) // Direct requests a direct link to destination without automatic bidirectional handling Direct(context.Context, Link) (net.Conn, error) // Handle returns a receving channel where Bidirectional request is made from a connected peer Handle() <-chan LinkConnection // NotifyClose returns a notifying channel, unblocks when the Peer disconnects NotifyClose() <-chan struct{} // Bye closes the session and LinkConnection channel Bye() error }
Peer defines the behavior of a multiplexer
Source Files
¶
Click to show internal directories.
Click to hide internal directories.