Documentation ¶
Index ¶
- Constants
- func CalculateAdvertiseAddress(bindAddr, advertiseAddr string) (string, int, error)
- func IsUnroutable(host string) bool
- type Peer
- func (p *Peer) Close(timeout time.Duration)
- func (p *Peer) Info() map[string]interface{}
- func (p *Peer) Join(peerType PeerType, initialMetadata PeerMetadata) error
- func (p *Peer) Name() string
- func (p *Peer) PeerState(id string) (PeerState, bool)
- func (p *Peer) PeerStates(types ...PeerType) map[string]PeerState
- func (p *Peer) Refresh() error
- func (p *Peer) SetLabels(labels []storepb.Label)
- func (p *Peer) SetTimestamps(mint int64, maxt int64)
- type PeerMetadata
- type PeerState
- type PeerType
Constants ¶
const ( DefaultPushPullInterval = 5 * time.Second DefaultGossipInterval = 5 * time.Second DefaultRefreshInterval = 60 * time.Second )
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 ¶
CalculateAdvertiseAddress deduce the external, advertise address that should be routable from other components.
func IsUnroutable ¶
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 ¶
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) 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) PeerStates ¶
PeerStates returns the custom state information for each peer by memberlist peer id (name).
func (*Peer) Refresh ¶
Refresh renews membership cluster, this will refresh DNS names and join newly added members
func (*Peer) SetLabels ¶
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 ¶
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.