cluster

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRefreshInterval = model.Duration(60 * time.Second)

	// Peer's network types. These are used as a predefined peer configurations for a specified network type.
	LocalNetworkPeerType = "local"
	LanNetworkPeerType   = "lan"
	WanNetworkPeerType   = "wan"
)
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

View Source
var (
	// NetworkPeerTypes is a list of available peers' network types.
	NetworkPeerTypes = []string{LocalNetworkPeerType, LanNetworkPeerType, WanNetworkPeerType}
)

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

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,
	secretKey []byte,
	networkType string,
) (*peer, error)

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

Types

type Peer

type Peer interface {
	PeerStateFetcher

	Name() string
	SetLabels(labels []storepb.Label)
	SetTimestamps(mint int64, maxt int64)
	Join(peerType PeerType, initialMetadata PeerMetadata) error
	PeerStates(types ...PeerType) map[string]PeerState
	Close(timeout time.Duration)
}

func NewNoop added in v0.2.0

func NewNoop() Peer

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 PeerStateFetcher added in v0.2.0

type PeerStateFetcher interface {
	PeerState(id string) (PeerState, bool)
}

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