cluster

package
v0.1.0-rc.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultPushPullInterval = 5 * time.Second
	DefaultGossipInterval   = 5 * time.Second
	DefaultRefreshInterval  = 60 * 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

func CalculateAdvertiseAddress

func CalculateAdvertiseAddress(bindAddr, advertiseAddr string) (string, int, error)

CalculateAdvertiseAddress deduce the external, advertise address that should be routable from other components.

func IsUnroutable

func IsUnroutable(host string) bool

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,
	advertiseStoreAPIAddr string,
	advertiseQueryAPIAddress string,
	knownPeers []string,
	waitIfEmpty bool,
	pushPullInterval time.Duration,
	gossipInterval time.Duration,
	refreshInterval 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(peerType PeerType, initialMetadata PeerMetadata) error

Join joins to the memberlist gossip cluster using knownPeers and given peerType and initialMetadata.

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) Refresh

func (p *Peer) Refresh() error

Refresh renews membership cluster, this will refresh DNS names and join newly added members

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 represents external labels for the peer. Only relevant for PeerTypeSource. Empty for other types.
	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 represents type of the peer holding the state.
	Type PeerType

	// StoreAPIAddr is a host:port address of gRPC StoreAPI of the peer holding the state. Required for PeerTypeSource and PeerTypeStore.
	StoreAPIAddr string
	// QueryAPIAddr is a host:port address of HTTP QueryAPI of the peer holding the state. Required for PeerTypeQuery type only.
	QueryAPIAddr string

	// Metadata holds metadata of the peer holding the state.
	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