ha

package
v0.0.0-...-6ee8545 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterNameLabel = "cluster"
View Source
const ReplicaNameLabel = "__replica__"

Variables

View Source
var ErrNoLeasesInRange = fmt.Errorf("no valid leases in range found")

Functions

func SetLeaderInMockService

func SetLeaderInMockService(service *Service, states []client.LeaseDBState)

Types

type Filter

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

Filter is a HA filter which filters data based on lease information it gets from the lease service.

func NewFilter

func NewFilter(service *Service) *Filter

NewFilter creates a new Filter based on the provided Service.

func (*Filter) Process

func (h *Filter) Process(_ *http.Request, wr *prompb.WriteRequest) error

FilterData validates and filters timeseries based on lease info from the service. When Prometheus & Promscale are running HA mode the below FilterData is used to validate leader replica samples & ha_locks in TimescaleDB.

type Service

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

Service contains the lease state for all prometheus clusters and logic for determining if a specific sample should be allowed to be inserted. Also it keeps the lease state up to date by periodically refreshing it from the database.

func MockNewHAService

func MockNewHAService() *Service

func NewService

func NewService(leaseClient client.LeaseClient) *Service

NewService constructs a new HA lease service with the supplied database connection and the default sync interval. The sync interval determines how often the leases for all clusters are refreshed from the database.

func NewServiceWith

func NewServiceWith(leaseClient client.LeaseClient, ticker util.Ticker, currentTimeFn func() time.Time) *Service

NewServiceWith constructs a new HA lease service with the leaseClient, ticker and a current time provide function. The ticker determines when the lease states for all clusters are refreshed from the database, the currentTimeFn determines the current time, used for deterministic tests.

func (*Service) CheckLease

func (s *Service) CheckLease(minT, maxT time.Time, clusterName, replicaName string) (
	allowInsert bool, acceptedMinT time.Time, err error,
)

CheckLease verifies the samples are from prom leader & in an expected time range.

An instance is selected a leader for a specific time range, which is expanded as newer samples come in from that leader, but samples before the granted lease are supposed to be dropped.

func (*Service) Close

func (s *Service) Close()

func (*Service) GetBackfillLeaseRange

func (s *Service) GetBackfillLeaseRange(start, end time.Time, cluster string, replica string) (time.Time, time.Time, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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