Documentation ¶
Overview ¶
Package transport provides a memberlist.Transport implementation
Index ¶
- Constants
- type Config
- type Listeners
- type Transport
- func (*Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) (net.Conn, error)
- func (t *Transport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)
- func (t *Transport) FinalAdvertiseAddr(ip string, port int) (net.IP, int, error)
- func (t *Transport) PacketCh() <-chan *memberlist.Packet
- func (t *Transport) Shutdown() error
- func (t *Transport) StreamCh() <-chan net.Conn
- func (t *Transport) WriteTo(b []byte, addr string) (time.Time, error)
- func (t *Transport) WriteToAddress(b []byte, addr memberlist.Address) (time.Time, error)
Constants ¶
const ( // DefaultBindRetry indicates how many times we will try binding a port DefaultBindRetry = 4 // DefaultPort indicates the default TCP/UDP Port to use when zero DefaultPort = 7946 )
const ( // Subsystem indicates our name on the logs Subsystem = "gossiptransport" // SubsystemLabel is the Field label for the Subsystem SubsystemLabel = "subsystem" // RemoteAddrLabel is the Field label for the remote party on a connection RemoteAddrLabel = "conn" // ListenerAddrLabel is the Field label for the local party on a connection ListenerAddrLabel = "addr" // PacketSizeLabel is the Field label used when logging message size PacketSizeLabel = "bytes" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // BindInterface is the list of interfaces to listen on BindInterface []string // BindAddress is the list of addresses to listen on BindAddress []string // BindPort is the port to listen on, for both TCP and UDP BindPort int // BindPortStrict tells us not to try other ports BindPortStrict bool // BindPortRetry indicates how many times we will try finding a port BindPortRetry int // ListenTCP is the helper to use to listen on a TCP port ListenTCP func(network string, laddr *net.TCPAddr) (*net.TCPListener, error) // ListenUDP is the helper to use to listen on a UDP port ListenUDP func(network string, laddr *net.UDPAddr) (*net.UDPConn, error) // OnError is called when a worker returns an error, before initiating // a shutdown OnError func(error) // Context Context context.Context // Logger is the optional logger to record events Logger slog.Logger }
Config is the configuration data for Transport
func (*Config) SetDefaults ¶
SetDefaults attempts to fill any configuration gap, specially the IP Addresses when interfaces are provided instead
type Listeners ¶
type Listeners struct { TCP []*net.TCPListener UDP []*net.UDPConn }
Listeners contains externally prepared listeners for our Transport
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements a memberlist.Transport that uses an slog.Logger, Cancellable Context, ListenTCP/ListenUDP callbacks
func New ¶
New creates a new Transport based on the given configuration or defaults. If succeeds, the created transport needs to be explicitly Close()ed once it's no longer used
func NewWithListeners ¶
NewWithListeners creates a new transport using preallocated listeners. If it fails, it's your responsibility to close them. If succeeds, the created transport needs to be explicitly Close()ed once it's no longer used
func (*Transport) DialAddressTimeout ¶
func (*Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) ( net.Conn, error)
DialAddressTimeout is used by memberlist to establish a TCP connection to a particular node
func (*Transport) DialTimeout ¶
DialTimeout is used by memberlist to connect to a particular TCP Address
func (*Transport) FinalAdvertiseAddr ¶
FinalAdvertiseAddr is used by memberlist to find what address and port to advertise to other nodes
func (*Transport) PacketCh ¶
func (t *Transport) PacketCh() <-chan *memberlist.Packet
PacketCh is used by memberlist to receive UDP messages
func (*Transport) Shutdown ¶
Shutdown closes the listening ports and cancels the workers, and then waits until all workers have exited
func (*Transport) WriteTo ¶
WriteTo is used by memberlist to send a UDP message to a particular address
func (*Transport) WriteToAddress ¶
WriteToAddress is used by memberlist to send a UDP message to a particular Node