discovery

package
v0.0.0-...-40b2247 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 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 {
	//unique id across Serf cluster. Serf uses hostname if not set
	NodeName string
	//Serf listens at this address and port for gossiping
	BindAddr string
	//Serf shares tags to other nodes in cluster and should use these tags for simple data that informs the cluster how to handle this node.
	Tags map[string]string
	//Configure new nodes to join an existing cluster. Set the field to the addresses of nodes in the cluster, and Serf's gossip protocol takes care of the rest to join your node to the cluster. (in prod: specify at least 3 addresses to make cluster resilient to one or two node failures or a disrupted network)
	StartJoinAddrs []string
}

type Handler

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

Handler represents some component in the service that needs to know when a server joins or leaves the cluster.

type Membership

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

Membership type wraps Serf to provide discovery and cluster membership to our service.

func New

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

func (*Membership) Leave

func (m *Membership) Leave() error

Leave tells the Serf member to leave the Serf cluster

func (*Membership) Members

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

Members return a point-in-time snapshot of thecluster's Serf members.

Jump to

Keyboard shortcuts

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