gossip

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gossip

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

Gossip is responsible for maintaining this nodes local State and propagating the state of the local node to the rest of the cluster.

At the gossip layer, a nodes state is represented as key-value pairs which are propagated around the cluster. These key-value pairs are then used to gossip based anti-entropy protocol. These key-value pairs are then used to build the local State.

func NewGossip

func NewGossip(
	clusterState *cluster.State,
	streamLn net.Listener,
	packetLn net.PacketConn,
	conf *gossip.Config,
	logger log.Logger,
) *Gossip

func (*Gossip) Close

func (g *Gossip) Close() error

func (*Gossip) JoinOnBoot

func (g *Gossip) JoinOnBoot(addrs []string) ([]string, error)

JoinOnBoot attempts to join an existing cluster by syncronising with the members at the given addresses.

This will only attempt to join once and won't retry.

func (*Gossip) JoinOnStartup

func (g *Gossip) JoinOnStartup(ctx context.Context, addrs []string) ([]string, error)

JoinOnStartup attempts to join an existing cluster by syncronising with the members at the given addresses.

This will retry 5 times (with backoff).

func (*Gossip) Leave

func (g *Gossip) Leave(ctx context.Context) error

Leave notifies the known members that this node is leaving the cluster.

This will attempt to sync with up to 3 nodes to ensure the leave status is propagated.

Returns an error if no known members could be notified.

func (*Gossip) Metrics

func (g *Gossip) Metrics() *gossip.Metrics

func (*Gossip) NodeState

func (g *Gossip) NodeState(id string) (*gossip.NodeState, bool)

NodeState returns the known state of the node with the given ID.

func (*Gossip) Nodes

func (g *Gossip) Nodes() []gossip.NodeMetadata

Nodes returns the metadata of all known nodes in the cluster.

type Status

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

func NewStatus

func NewStatus(gossip *Gossip) *Status

func (*Status) Register

func (s *Status) Register(group *gin.RouterGroup)

Jump to

Keyboard shortcuts

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