Documentation ¶
Overview ¶
Simple Memberlist is a wrapper around hashicorp memberlist, that leverages the gossip protocol and exposes a simpler interface. Main features include: automatic rejoining a list of cluster anchors, providing a channel of node changes, encoding and decoding of node metadata, plus caching of decoded metadata.
Index ¶
- func NewTransport(config *memberlist.NetTransportConfig, logger logr.Logger) (*instrumentedTransport, error)
- type ClusterData
- type ClusterState
- type Instrumentation
- type Memberlist
- func (m *Memberlist[M, S, MP, SP]) Events() <-chan struct{}
- func (m *Memberlist[M, S, MP, SP]) GetBroadcasts(overhead, limit int) [][]byte
- func (m *Memberlist[M, S, MP, SP]) Instr() Instrumentation
- func (m *Memberlist[M, S, MP, SP]) LocalState(join bool) []byte
- func (m *Memberlist[M, S, MP, SP]) MergeRemoteState(buf []byte, join bool)
- func (m *Memberlist[M, S, MP, SP]) NodeMeta(limit int) []byte
- func (m *Memberlist[M, S, MP, SP]) Nodes() []MP
- func (m *Memberlist[M, S, MP, SP]) NotifyConflict(node, other *memberlist.Node)
- func (m *Memberlist[M, S, MP, SP]) NotifyJoin(n *memberlist.Node)
- func (m *Memberlist[M, S, MP, SP]) NotifyLeave(n *memberlist.Node)
- func (m *Memberlist[M, S, MP, SP]) NotifyMsg([]byte)
- func (m *Memberlist[M, S, MP, SP]) NotifyUpdate(n *memberlist.Node)
- func (m *Memberlist[M, S, MP, SP]) Run() error
- func (m *Memberlist[M, S, MP, SP]) Start() error
- func (m *Memberlist[M, S, MP, SP]) Update()
- type MetaPointer
- type NodeMeta
- type StatePointer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTransport ¶
func NewTransport(config *memberlist.NetTransportConfig, logger logr.Logger) (*instrumentedTransport, error)
Create a new instrumented transport
Types ¶
type ClusterData ¶
Cluster data can be encoded and decoded to bytes, required by Memberlist wire protocol
type ClusterState ¶
type ClusterState interface { ClusterData Merge([]byte) (bool, error) }
Cluster state is node data that can be merged, crdt-style
type Instrumentation ¶
type Instrumentation interface { // Instrumentation data was updated Updates() <-chan struct{} // Get the current minimum observed path MTU with any other node in the // cluster, useful for setting cluster-wide MTU MinMTU() int }
type Memberlist ¶
type Memberlist[M any, S any, MP MetaPointer[M], SP StatePointer[S]] struct { Meta MP State SP // contains filtered or unexported fields }
func New ¶
func New[M any, S any, MP MetaPointer[M], SP StatePointer[S]](nodeName string, nodeIP net.IP, port int, anchors []string, key []byte, logger logr.Logger) *Memberlist[M, S, MP, SP]
func (*Memberlist[M, S, MP, SP]) Events ¶
func (m *Memberlist[M, S, MP, SP]) Events() <-chan struct{}
Get a channel for notifications of network changes
func (*Memberlist[M, S, MP, SP]) GetBroadcasts ¶
func (m *Memberlist[M, S, MP, SP]) GetBroadcasts(overhead, limit int) [][]byte
Cluster implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) Instr ¶
func (m *Memberlist[M, S, MP, SP]) Instr() Instrumentation
Get the instrumentation interface
func (*Memberlist[M, S, MP, SP]) LocalState ¶
func (m *Memberlist[M, S, MP, SP]) LocalState(join bool) []byte
Cluster implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) MergeRemoteState ¶
func (m *Memberlist[M, S, MP, SP]) MergeRemoteState(buf []byte, join bool)
Clutser implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) NodeMeta ¶
func (m *Memberlist[M, S, MP, SP]) NodeMeta(limit int) []byte
Cluter implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) Nodes ¶
func (m *Memberlist[M, S, MP, SP]) Nodes() []MP
Get the list of current cluster nodes
func (*Memberlist[M, S, MP, SP]) NotifyConflict ¶
func (m *Memberlist[M, S, MP, SP]) NotifyConflict(node, other *memberlist.Node)
Cluster implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) NotifyJoin ¶
func (m *Memberlist[M, S, MP, SP]) NotifyJoin(n *memberlist.Node)
Cluster implements the EventDelegate interface
func (*Memberlist[M, S, MP, SP]) NotifyLeave ¶
func (m *Memberlist[M, S, MP, SP]) NotifyLeave(n *memberlist.Node)
Node implements the EventDelegate interface
func (*Memberlist[M, S, MP, SP]) NotifyMsg ¶
func (m *Memberlist[M, S, MP, SP]) NotifyMsg([]byte)
Clutser implements the memberlist.Delegate interface
func (*Memberlist[M, S, MP, SP]) NotifyUpdate ¶
func (m *Memberlist[M, S, MP, SP]) NotifyUpdate(n *memberlist.Node)
Node implements the EventDelegate interface
func (*Memberlist[M, S, MP, SP]) Run ¶
func (m *Memberlist[M, S, MP, SP]) Run() error
Run the memberlist cluster main loop, that awaits cluster changes, maintains the cluster state and propagates information to channels
func (*Memberlist[M, S, MP, SP]) Start ¶
func (m *Memberlist[M, S, MP, SP]) Start() error
Start the memberlist cluster by listening on main sockets
func (*Memberlist[M, S, MP, SP]) Update ¶
func (m *Memberlist[M, S, MP, SP]) Update()
Update the current node
type MetaPointer ¶
Pointer type to node meta, for generics trickery This is required because we create meta instances while the interface specification requires pointer receivers for decoding
type NodeMeta ¶
type NodeMeta interface { ClusterData }
type StatePointer ¶
type StatePointer[S any] interface { ClusterState *S }
Pointer type to cluster state, for generics trickery This is required because we create state instances while the interface specification requires pointer receivers for decoding and merging