lidar

package
v6.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChecker

func NewChecker(
	logger lager.Logger,
	checkFactory db.CheckFactory,
	engine engine.Engine,
	checkRateCalculator RateCalculator,
) *checker

func NewScanner

func NewScanner(
	logger lager.Logger,
	checkFactory db.CheckFactory,
	secrets creds.Secrets,
	defaultCheckTimeout time.Duration,
	defaultCheckInterval time.Duration,
	defaultWithWebhookCheckInterval time.Duration,
) *scanner

Types

type CheckRateCalculator

type CheckRateCalculator struct {
	MaxChecksPerSecond       int
	ResourceCheckingInterval time.Duration

	CheckableCounter CheckableCounter
}

func (CheckRateCalculator) RateLimiter

func (c CheckRateCalculator) RateLimiter() (Limiter, error)

RateLimiter determines the rate at which the checks should be limited to per second.

It is dependent on the max checks per second configuration, where if it is configured to -1 then it there is no limit, if it is > 0 then it is set to its configured value and if it is 0 (which is default) then it is calculated using the number of checkables and the resource checking interval.

The calculated limit is determined by finding the ideal number of checks to run per second in order to check all the checkables in the database within the resource checking interval. By enforcing that ideal rate of checks, it will help spread out the number of checks that are started within the same interval.

type CheckableCounter

type CheckableCounter interface {
	CheckableCount() (int, error)
}

type Limiter

type Limiter interface {
	Wait(context.Context) error
}

type RateCalculator

type RateCalculator interface {
	RateLimiter() (Limiter, error)
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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