discovery

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// NodeName acts as the node's unique identifier across the Serf cluster.
	NodeName string

	// Serf listens on this address for gossiping. [Ref: gossip protocol serf]
	BindAddr string

	// Used for sharing data to other nodes in the cluster. This information is
	// used by the cluster to decide how to handle this node.
	Tags map[string]string

	// Used for joining a new node to the cluster. Joining a new node requires
	// pointing to atleast one in-cluster node. In a prod env., it's advisable
	// to specify at least 3 addrs to increase cluster resliency.
	StartJoinAddrs []string
}

Configuration of a single node in a Surf cluster.

type Handler

type Handler interface {
	Join(name, addr string) error
	Leave(name string) error
}

Handler for cluster membership modification operations.

type Membership

type Membership struct {
	Config
	// contains filtered or unexported fields
}

Represents membership of a node to a cluster. It wraps a Serf instance, providing a handle to cluster membership operations.

func New

func New(handler Handler, config Config) (*Membership, error)

Creates a new Serf cluster member with the given config and cluster handler. It internally setups up the Serf configuration and event handlers.

func (*Membership) Leave

func (m *Membership) Leave() error

Telles this member to leave the Serf cluster.

func (*Membership) Members

func (m *Membership) Members() []serf.Member

Returns a point-in-time snapshot of the cluster's Serf members.

Jump to

Keyboard shortcuts

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