watcher

package
v1.15.12 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package Watcher is responsible for watching latest metrics from metrics provider via a fetcher client. It exposes an HTTP REST endpoint to get these metrics, in addition to application API via clients This also uses a fast json parser

Index

Constants

View Source
const (
	BaseUrl        = "/watcher"
	HealthCheckUrl = "/healthy"
	MertricUrl     = "/metric"
	JobUrl         = "/job"
	ScheduleUrl    = "/schedule"
)
View Source
const (
	FirstNode            = "worker-1"
	SecondNode           = "worker-2"
	TestServerClientName = "TestServerClient"
)

Variables

View Source
var FifteenMinutesMetricsMap = map[string][]metricstype.Metric{
	FirstNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 26,
		},
	},
	SecondNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 60,
		},
	},
}
View Source
var FiveMinutesMetricsMap = map[string][]metricstype.Metric{
	FirstNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 21,
		},
	},
	SecondNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 50,
		},
	},
}
View Source
var TenMinutesMetricsMap = map[string][]metricstype.Metric{
	FirstNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 22,
		},
	},
	SecondNode: {
		{
			Name:  "test-cpu",
			Type:  metricstype.CPU,
			Value: 65,
		},
	},
}

Functions

func NewTestMetricsServerClient

func NewTestMetricsServerClient() metricsprovider.MetricsProviderClient

Types

type JobRequest

type JobRequest struct {
	FilePath string `json:"file_path"`
	MD5      string `json:"md5"`
}

type Watcher

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

func NewWatcher

func NewWatcher(client metricsprovider.MetricsProviderClient) *Watcher

NewWatcher Returns a new initialised Watcher

func (*Watcher) GetLatestWatcherMetrics

func (w *Watcher) GetLatestWatcherMetrics(duration string) (*metricstype.WatcherMetrics, error)

GetLatestWatcherMetrics It starts from 15 minute window, and falls back to 10 min, 5 min windows subsequently if metrics are not present. StartWatching() should be called before calling this.

func (*Watcher) Healthy

func (w *Watcher) Healthy() error

func (*Watcher) StartWatching

func (w *Watcher) StartWatching(shutdown chan struct{})

StartWatching This function needs to be called to begin actual watching

Jump to

Keyboard shortcuts

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