Documentation ¶
Index ¶
Constants ¶
const ClusterNameLabel = "cluster"
const ReplicaNameLabel = "__replica__"
Variables ¶
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.
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.