backends

package
v0.0.0-...-e07aa5a Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExceedsMTU = fmt.Errorf("payload size exceeds MTU")

Functions

func RunDialer

func RunDialer(ctx context.Context, pr ProtocolRunner, cost float32, dialer ConnFunc)

RunDialer abstractly implements retry logic for repeatedly dialing a peer until it connects

func RunListener

func RunListener(ctx context.Context, pr ProtocolRunner, cost float32, acceptor ConnFunc)

RunListener abstractly implements the accept loop of a listener

Types

type BackendConnection

type BackendConnection interface {
	MTU() int
	WriteMessage([]byte) error
	ReadMessage() ([]byte, error)
	Close() error
	SetReadDeadline(time.Time) error
	SetWriteDeadline(time.Time) error
	IsServer() bool
}

BackendConnection represents a single back-end connection. Message transport need not be reliable, but Backends must guarantee that whole messages transit the network intact - ie, that ReadMessage, if it returns anything, always returns the entire message that was provided (on another node) to WriteMessage, not just a fragment of it.

type ConnFunc

type ConnFunc func() (BackendConnection, error)

ConnFunc is a type of function that gets a new BackendConnection, such as by dialing or accepting

type ProtocolRunner

type ProtocolRunner interface {
	RunProtocol(context.Context, float32, BackendConnection)
}

ProtocolRunner is called by backends to run a protocol over a connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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