worker

package
v0.0.0-...-c4caace Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckLogger

type CheckLogger struct {
	Check check.Check
}

CheckLogger is the object responsible for logging the information generated during the running of the check

func (*CheckLogger) CheckFinished

func (cl *CheckLogger) CheckFinished()

CheckFinished is used to log that the check has completed

func (*CheckLogger) CheckStarted

func (cl *CheckLogger) CheckStarted()

CheckStarted is used to log that the check is about to run

func (*CheckLogger) Debug

func (cl *CheckLogger) Debug(message string)

Debug is used to log a message for a check that may be useful in debugging

func (*CheckLogger) Error

func (cl *CheckLogger) Error(checkErr error)

Error is used to log an error that occurred during the invocation of the check

type UtilizationTracker

type UtilizationTracker interface {
	// Start activates the polling ticker for collection of data.
	Start() error

	// Stop is invoked when a worker is about to exit to remove the instance's
	// expvars.
	Stop() error

	// CheckStarted starts tracking the start time of a check.
	CheckStarted(bool)

	// CheckFinished ends tracking the the runtime of a check previously registered
	// with `CheckStarted()`.
	CheckFinished()

	// IsRunningLongCheck returns true if we are currently running a check
	// that is meant to be of indefinite duration (e.g. jmxfetch checks).
	IsRunningLongCheck() bool
}

UtilizationTracker is the interface that encapsulates the API around the utilizationTracker object.

func NewUtilizationTracker

func NewUtilizationTracker(
	workerName string,
	windowSize time.Duration,
	pollingInterval time.Duration,
) (UtilizationTracker, error)

NewUtilizationTracker instantiates and configures a utilization tracker that calculates the values and publishes them to expvars

type Worker

type Worker struct {
	ID   int
	Name string
	// contains filtered or unexported fields
}

Worker is an object that encapsulates the logic to manage a loop of processing checks over the provided `PendingCheckChan`

func NewWorker

func NewWorker(
	runnerID int,
	ID int,
	pendingChecksChan chan check.Check,
	checksTracker *tracker.RunningChecksTracker,
	shouldAddCheckStatsFunc func(id check.ID) bool,
) (*Worker, error)

NewWorker returns an instance of a `Worker` after parameter sanity checks are passed

func (*Worker) Run

func (w *Worker) Run()

Run waits for checks and run them as long as they arrive on the channel

Jump to

Keyboard shortcuts

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