sml

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

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

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

type ClusterData interface {
	Encode() ([]byte, error)
	Decode([]byte) error
	String() string
}

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

type MetaPointer[M any] interface {
	NodeMeta
	*M
}

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

Jump to

Keyboard shortcuts

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