memberlist

package
v3.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport is a memberlist.Transport implementation that uses TCP for both packet and stream operations ("packet" and "stream" are terms used by memberlist). It uses a new TCP connections for each operation. There is no connection reuse.

func NewTransport

func NewTransport(config TransportConfig) (*Transport, error)

NewTransport returns new tcp-based transport with the given configuration. On success all the network listeners will be created and listening.

func (*Transport) DialAddressTimeout

func (t *Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Duration) (net.Conn, error)

func (*Transport) DialTimeout

func (t *Transport) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)

DialTimeout is used to create a connection that allows memberlist to perform two-way communication with a peer.

func (*Transport) FinalAdvertiseAddr

func (t *Transport) FinalAdvertiseAddr(ip string, port int) (net.IP, int, error)

FinalAdvertiseAddr is given the user's configured values (which might be empty) and returns the desired IP and port to advertise to the rest of the cluster. (Copied from memberlist' net_transport.go)

func (*Transport) GetAutoBindPort

func (t *Transport) GetAutoBindPort() int

GetAutoBindPort returns the bind port that was automatically given by the kernel, if a bind port of 0 was given.

func (*Transport) PacketCh

func (t *Transport) PacketCh() <-chan *memberlist.Packet

PacketCh returns a channel that can be read to receive incoming packets from other peers.

func (*Transport) Shutdown

func (t *Transport) Shutdown() error

Shutdown is called when memberlist is shutting down; this gives the transport a chance to clean up any listeners.

func (*Transport) StreamCh

func (t *Transport) StreamCh() <-chan net.Conn

StreamCh returns a channel that can be read to handle incoming stream connections from other peers.

func (*Transport) WriteTo

func (t *Transport) WriteTo(b []byte, addr string) (time.Time, error)

WriteTo is a packet-oriented interface that fires off the given payload to the given address.

func (*Transport) WriteToAddress

func (t *Transport) WriteToAddress(b []byte, addr memberlist.Address) (time.Time, error)

type TransportConfig

type TransportConfig struct {
	// BindAddrs is a list of addresses to bind to for both TCP and UDP
	// communications.
	BindAddrs []string

	// BindPort is the port to listen on, for each address above.
	BindPort int

	PacketDialTimeout  time.Duration
	PacketWriteTimeout time.Duration

	// Logger is a logger for operator messages.
	Logger log.Logger

	TLSEnabled   bool
	TLS          *tls.Config
	DebugEnabled bool
}

TransportConfig is used to configure a net transport.

Jump to

Keyboard shortcuts

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