dispatcher

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	db *database.DB,
	providePredictorFn predictor.ProvideFn,
	notifier alert.Manager,
	shutdownCh chan<- error,
	opts ...Option,
) (*manager, error)

New return manager

Types

type CollectPredictor

type CollectPredictor interface {
	Collector
	Predictor
}

Aggregation interface for Collector and Predictor interfaces

type Collector

type Collector interface {
	// The method accepts data from outside and writes it to the queue
	Collect(in ...model.Metric) error
}

Collector defines the behavior of the service for data storage and analysis

type Config

type Config struct {
	// Timer for performing data cleaning operations in the DB
	RebuildDBTime time.Duration `envconfig:"SOD_OUTLIER_REBUILD_DB_TIME" default:"15s"`
	// Skipping the first n metrics that are not passed through predictor, accumulating the dataset
	SkipItems int `envconfig:"SOD_OUTLIER_SKIP_ITEMS"`
	// maximum number of elements in the DB for each entity
	MaxItemsStored int `envconfig:"SOD_OUTLIER_MAX_ITEMS_STORED" default:"1000000"`
	// maximum retention period for elements in the DB for each entity
	MaxStorageTime time.Duration `envconfig:"SOD_OUTLIER_MAX_STORAGE_TIME" default:"0s"`
	// Critical buffer size in dbTxExecutor DP where data is flushed to disk
	DBFlushSize int `envconfig:"SOD_DB_FLUSH_SIZE" default:"10"`
	// Critical time of life in dbTxExecutor buffer in which data to be flushed to disk
	DBFlushTime time.Duration `envconfig:"SOD_DB_FLUSH_TIME" default:"5s"`
	//  Allow adding data to the dataset
	AllowAppendData bool `envconfig:"SOD_OUTLIER_ALLOW_APPEND_DATA" default:"true"`
	// Allow adding outliers to the dataset
	AllowAppendOutlier bool `envconfig:"SOD_OUTLIER_ALLOW_APPEND_OUTLIER" default:"true"`
}

type Manager

type Manager interface {
	CollectPredictor
	// Start method of the service
	Run(context.Context) error
	// Method for stopping the service
	Stop()
}

The interface defines the behavior of the Manager instance with all available methods. This interface defines the behavior of the background service.

type Option

type Option func(*manager)

func WithAllowAppendData

func WithAllowAppendData(t bool) Option

func WithAllowAppendOutlier

func WithAllowAppendOutlier(t bool) Option

func WithDBFlushSize

func WithDBFlushSize(n int) Option

func WithDBFlushTime

func WithDBFlushTime(t time.Duration) Option

func WithMaxItemsStored

func WithMaxItemsStored(n int) Option

func WithMaxStorageTime

func WithMaxStorageTime(t time.Duration) Option

func WithRebuildDBTime

func WithRebuildDBTime(t time.Duration) Option

func WithSkipItems

func WithSkipItems(n int) Option

type Options

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

type Predictor

type Predictor interface {
	// The method determines whether the data is an outlier
	Predict(entityID string, in predictor.DataPoint) (*predictor.Conclusion, error)
}

The interface defines the behavior of the service only for predictions

type ProvideFn

type ProvideFn func(alert.Manager, chan<- error) (Manager, error)

Contract for returning the Manager instance

Jump to

Keyboard shortcuts

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