cluster

package
v0.15.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPushPullInterval = 60 * time.Second
	DefaultGossipInterval   = 200 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

Channel allows clients to send messages for a specific state type that will be broadcasted in a best-effort manner.

func (*Channel) Broadcast

func (c *Channel) Broadcast(b []byte)

Broadcast enqueues a message for broadcasting.

type Peer

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

Peer is a single peer in a gossip cluster.

func Join

func Join(
	l log.Logger,
	reg prometheus.Registerer,
	bindAddr string,
	advertiseAddr string,
	knownPeers []string,
	waitIfEmpty bool,
	pushPullInterval time.Duration,
	gossipInterval time.Duration,
) (*Peer, error)

func (*Peer) AddState

func (p *Peer) AddState(key string, s State) *Channel

AddState adds a new state that will be gossiped. It returns a channel to which broadcast messages for the state can be sent.

func (*Peer) ClusterSize

func (p *Peer) ClusterSize() int

ClusterSize returns the current number of alive members in the cluster.

func (*Peer) Info

func (p *Peer) Info() map[string]interface{}

Info returns a JSON-serializable dump of cluster state. Useful for debug.

func (*Peer) Leave

func (p *Peer) Leave(timeout time.Duration) error

Leave the cluster, waiting up to timeout.

func (*Peer) Name

func (p *Peer) Name() string

Name returns the unique ID of this peer in the cluster.

func (*Peer) Peers

func (p *Peer) Peers() []*memberlist.Node

Peers returns the peers in the cluster.

func (*Peer) Position

func (p *Peer) Position() int

Position returns the position of the peer in the cluster.

func (*Peer) Self

func (p *Peer) Self() *memberlist.Node

Self returns the node information about the peer itself.

type State

type State interface {
	// MarshalBinary serializes the underlying state.
	MarshalBinary() ([]byte, error)

	// Merge merges serialized state into the underlying state.
	Merge(b []byte) error
}

State is a piece of state that can be serialized and merged with other serialized state.

Directories

Path Synopsis
Package clusterpb is a generated protocol buffer package.
Package clusterpb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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