gossip

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExternalIP

func ExternalIP() (string, error)

ExternalIP returns the first non-loopback IPv4 address

Types

type IGossip

type IGossip interface {
	SyncNodes(ctx context.Context, consistent *hash.ConsistentHash, nodeName, port string)
	// Shutdown gracefully stops the gossip protocol and performs
	// any necessary cleanup. It returns an error if the shutdown
	// process encounters any issues.
	Shutdown() error
}

IGossip is an interface that represents the basic operations of a gossip-based membership protocol. Implementations of this interface should provide mechanisms for synchronizing cluster membership and managing the lifecycle of the gossip protocol.

func InitMemberList

func InitMemberList(nodes, name string) (IGossip, error)

InitMemberList initializes a memberlist instance with the given

type Serf added in v0.4.7

type Serf struct {
	Enabled bool

	EventCh chan serf.Event
	// contains filtered or unexported fields
}

Serf structure with the serf instance and EventCh channel

func NewSerfGossip added in v0.4.7

func NewSerfGossip(node string) (*Serf, error)

NewSerfGossip is a function that initializes and returns a new Serf instance

func (*Serf) Shutdown added in v0.4.7

func (s *Serf) Shutdown() error

Shutdown is a method on the Serf struct that gracefully shuts down the Serf agent. It first leaves the Serf cluster, and then shuts down the agent. It returns any errors that occurred during the shutdown process.

func (*Serf) SyncNodes added in v0.4.7

func (s *Serf) SyncNodes(ctx context.Context, consistent *hash.ConsistentHash, nodeName, port string)

SyncNodes is a method on the Serf struct that synchronizes nodes between the Serf cluster and the provided ConsistentHash. It adds new nodes that join the cluster, and removes nodes that leave or fail. The synchronization is done in a loop which continues indefinitely until the provided context is done.

Jump to

Keyboard shortcuts

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