cluster

package
v0.1.0-rc.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultPushPullInterval = 5 * time.Second
	DefaultGossipInterval   = 5 * time.Second
)
View Source
const (
	// PeerTypeStore is for peers that implements StoreAPI and are used for browsing historical data.
	PeerTypeStore = "store"
	// PeerTypeSource is for peers that implements StoreAPI and are used for scraping data. They tend to
	// have data accessible only for short period.
	PeerTypeSource = "source"

	// PeerTypeQuery is for peers that implements QueryAPI and are used for querying the metrics.
	PeerTypeQuery = "query"
)

Constants holding valid PeerType values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

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

Peer is a single peer in a gossip cluster.

func New

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

New returns "alone" peer that is ready to join.

func (*Peer) Close

func (p *Peer) Close(timeout time.Duration)

Close leaves the cluster waiting up to timeout and shutdowns peer if cluster left. TODO(bplotka): Add this method into run.Group closing logic for each command. This will improve graceful shutdown.

func (*Peer) Info

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

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

func (*Peer) Join

func (p *Peer) Join(initialState PeerState) error

Join joins to the memberlist gossip cluster using knownPeers and initialState.

func (*Peer) Name

func (p *Peer) Name() string

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

func (*Peer) PeerState

func (p *Peer) PeerState(id string) (PeerState, bool)

PeerState returns the custom state information by memberlist peer name.

func (*Peer) PeerStates

func (p *Peer) PeerStates(types ...PeerType) map[string]PeerState

PeerStates returns the custom state information for each peer by memberlist peer id (name).

func (*Peer) SetLabels

func (p *Peer) SetLabels(labels []storepb.Label)

SetLabels updates internal metadata's labels stored in PeerState for this peer. Note that this data will be propagated based on gossipInterval we set.

func (*Peer) SetTimestamps

func (p *Peer) SetTimestamps(mint int64, maxt int64)

SetTimestamps updates internal metadata's timestamps stored in PeerState for this peer. Note that this data will be propagated based on gossipInterval we set.

type PeerMetadata

type PeerMetadata struct {
	Labels []storepb.Label

	// MinTime indicates the minTime of the oldest block available from this peer.
	MinTime int64
	// MaxTime indicates the maxTime of the youngest block available from this peer.
	MaxTime int64
}

PeerMetadata are the information that can change in runtime of the peer.

type PeerState

type PeerState struct {
	Type    PeerType
	APIAddr string

	Metadata PeerMetadata
}

PeerState contains state for the peer.

type PeerType

type PeerType string

PeerType describes a peer's role in the cluster.

func PeerTypesStoreAPIs

func PeerTypesStoreAPIs() []PeerType

PeerTypesStoreAPIs gives a PeerType that allows all types that exposes StoreAPI.

Jump to

Keyboard shortcuts

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