cluster

package
v0.0.0-...-4aff305 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: GPL-3.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PeerTypeStore serves the store API
	PeerTypeStore members.PeerType = "store"
)

Variables

This section is empty.

Functions

func CalculateAdvertiseAddress

func CalculateAdvertiseAddress(bindAddr, advertiseAddr string) (net.IP, error)

CalculateAdvertiseAddress attempts to clone logic from deep within memberlist (NetTransport.FinalAdvertiseAddr) in order to surface its conclusions to the application, so we can provide more actionable error messages if the user has inadvertently mis-configured their cluster.

https://github.com/hashicorp/memberlist/blob/022f081/net_transport.go#L126

func ParsePeerType

func ParsePeerType(t string) (members.PeerType, error)

ParsePeerType parses a potential peer type and errors out if it's not a known valid type.

Types

type Peer

type Peer interface {
	members.EventBus

	// Join the cluster
	Join() (int, error)

	// Leave the cluster.
	Leave() error

	// Name returns unique ID of this peer in the cluster.
	Name() string

	// Address returns host:port of this peer in the cluster.
	Address() string

	// ClusterSize returns the total size of the cluster from this node's
	// perspective.
	ClusterSize() int

	// State returns a JSON-serializable dump of cluster state.
	// Useful for debug.
	State() map[string]interface{}

	// Current API host:ports for the given type of node.
	// Bool defines if you want to include the current local node.
	Current(peerType members.PeerType, includeLocal bool) ([]string, error)

	// Close and shutdown the peer
	Close()
}

Peer represents the node with in the cluster.

func NewPeer

func NewPeer(
	members members.Members,
	logger log.Logger,
) Peer

NewPeer creates or joins a cluster with the existing peers. We will listen for cluster communications on the bind addr:port. We advertise a PeerType HTTP API, reachable on apiPort.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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