pathteststore

package
v0.0.0-...-4b48ac8 Latest Latest
Warning

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

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

Documentation

Overview

Package pathteststore handle pathtest storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ContextsLimit is the maximum number of contexts to keep in the store
	ContextsLimit int
	// TTL is the duration a Pathtest should run from discovery.
	// If a Pathtest is added again before the TTL expires, the TTL is reset to this duration.
	TTL time.Duration
	// Interval defines how frequently pathtests should run
	Interval time.Duration
	// MaxPerMinute is a "circuit breaker" config that limits pathtests. 0 is unlimited.
	MaxPerMinute int
	// MaxBurstDuration is how long pathtest "budget" can build up in the rate limiter
	MaxBurstDuration time.Duration
}

Config is the configuration for the PathtestStore

type PathtestContext

type PathtestContext struct {
	Pathtest *common.Pathtest
	// contains filtered or unexported fields
}

PathtestContext contains Pathtest information and additional flush related data

func (*PathtestContext) LastFlushInterval

func (p *PathtestContext) LastFlushInterval() time.Duration

LastFlushInterval returns last flush interval

func (*PathtestContext) SetLastFlushInterval

func (p *PathtestContext) SetLastFlushInterval(lastFlushInterval time.Duration)

SetLastFlushInterval sets last flush interval

type Store

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

Store is used to accumulate aggregated contexts

func NewPathtestStore

func NewPathtestStore(config Config, logger log.Component, statsdClient ddgostatsd.ClientInterface, timeNow func() time.Time) *Store

NewPathtestStore creates a new Store

func (*Store) Add

func (f *Store) Add(pathtestToAdd *common.Pathtest)

Add new pathtest

func (*Store) Flush

func (f *Store) Flush() []*PathtestContext

Flush will flush specific Pathtest context (distinct hash) if nextRun is reached once a Pathtest context is flushed nextRun will be updated to the next flush time

ttl: ttl defines the duration we should keep a specific PathtestContext in `Store.contexts` after `lastSuccessfulFlush`. // Flow context in `Store.contexts` map will be deleted if `ttl` is reached to avoid keeping Pathtest context that are not seen anymore. We need to keep PathtestContext (contains `nextRun` and `lastSuccessfulFlush`) after flush to be able to flush at regular interval (`flushInterval`). Example, after a flush, PathtestContext will have a new nextRun, that will be the next flush time for new contexts being added.

func (*Store) GetContextsCount

func (f *Store) GetContextsCount() int

GetContextsCount returns pathtest contexts count

Jump to

Keyboard shortcuts

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