controller

package
v0.0.0-...-234d38c Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInternalCollectorCurrentlyQueuedTasksCount

func NewInternalCollectorCurrentlyQueuedTasksCount() prometheus.Collector

NewInternalCollectorCurrentlyQueuedTasksCount returns a new collector for the mre_currently_queued_tasks_count metric.

func NewInternalCollectorExecutedTasksCount

func NewInternalCollectorExecutedTasksCount() prometheus.Collector

NewInternalCollectorExecutedTasksCount returns a new collector for the mre_executed_tasks_count metric.

func NewInternalCollectorMetricsCount

func NewInternalCollectorMetricsCount() prometheus.Collector

NewInternalCollectorMetricsCount returns a new collector for the mre_metrics_count metric.

func StoreDelMetric

func StoreDelMetric(ctx context.Context, s store.Store, m schemas.Metric)

func StoreGetMetric

func StoreGetMetric(ctx context.Context, s store.Store, m *schemas.Metric)

func StoreSetMetric

func StoreSetMetric(ctx context.Context, s store.Store, m schemas.Metric)

Types

type Controller

type Controller struct {
	Config config.Config

	// UUID is used to identify this controller/process amongst others when
	// the exporter is running in cluster mode, leveraging Redis.
	UUID           uuid.UUID
	Redis          *redis.Client
	TaskController TaskController
	Store          store.Store

	Collectors RegistryCollectors
}

func New

func New(ctx context.Context, cfg config.Config, version string) (c Controller, err error)

New creates a new controller.

func (*Controller) HealthCheckHandler

func (c *Controller) HealthCheckHandler(ctx context.Context) (h healthcheck.Handler)

HealthCheckHandler ..

func (*Controller) MetricsHandler

func (c *Controller) MetricsHandler(w http.ResponseWriter, r *http.Request)

MetricsHandler ..

func (*Controller) RegisterCollector

func (c *Controller) RegisterCollector(ctx context.Context, collectors RegistryCollectors)

RegisterCollector is used to add collectors to the registry

func (*Controller) RegisterTasks

func (c *Controller) RegisterTasks(n schemas.TaskType, h interface{})

RegisterTasks is used to load the list of tasks to be handled.

func (*Controller) Schedule

func (c *Controller) Schedule(ctx context.Context, tt schemas.TaskType, cfg config.SchedulerConfig)

Schedule ..

func (*Controller) ScheduleRedisSetKeepalive

func (c *Controller) ScheduleRedisSetKeepalive(ctx context.Context)

ScheduleRedisSetKeepalive will ensure that whilst the process is running, a key is periodically updated within Redis to let other instances know this one is alive and processing tasks.

func (*Controller) ScheduleTask

func (c *Controller) ScheduleTask(ctx context.Context, tt schemas.TaskType, uniqueID string, args ...interface{})

ScheduleTask ..

func (*Controller) ScheduleTaskWithTicker

func (c *Controller) ScheduleTaskWithTicker(ctx context.Context, tt schemas.TaskType, intervalSeconds int)

ScheduleTaskWithTicker ..

func (*Controller) UnqueueTask

func (c *Controller) UnqueueTask(ctx context.Context, tt schemas.TaskType, uniqueID string)

func (*Controller) WebhookHandler

func (c *Controller) WebhookHandler(w http.ResponseWriter, r *http.Request)

WebhookHandler ..

type Registry

type Registry struct {
	*prometheus.Registry

	InternalCollectors struct {
		CurrentlyQueuedTasksCount prometheus.Collector
		ExecutedTasksCount        prometheus.Collector
		MetricsCount              prometheus.Collector
	}

	Collectors RegistryCollectors
}

Registry wraps a pointer of prometheus.Registry.

func NewRegistry

func NewRegistry(ctx context.Context, collectors RegistryCollectors) *Registry

NewRegistry initialize a new registry.

func (*Registry) ExportInternalMetrics

func (r *Registry) ExportInternalMetrics(
	ctx context.Context,
	s store.Store,
) (err error)

ExportInternalMetrics ..

func (*Registry) ExportMetrics

func (r *Registry) ExportMetrics(metrics schemas.Metrics)

ExportMetrics ..

func (*Registry) GetCollector

func (r *Registry) GetCollector(kind schemas.MetricKind) prometheus.Collector

GetCollector ..

func (*Registry) RegisterCollectors

func (r *Registry) RegisterCollectors() error

RegisterCollectors add all our metrics to the registry.

func (*Registry) RegisterInternalCollectors

func (r *Registry) RegisterInternalCollectors()

RegisterInternalCollectors declare our internal collectors to the registry.

type RegistryCollectors

type RegistryCollectors map[schemas.MetricKind]prometheus.Collector

RegistryCollectors ..

type TaskController

type TaskController struct {
	Factory                  taskq.Factory
	Queue                    taskq.Queue
	TaskMap                  *taskq.TaskMap
	TaskSchedulingMonitoring map[schemas.TaskType]*schemas.TaskSchedulingStatus
}

TaskController holds task related metrics.

func NewTaskController

func NewTaskController(ctx context.Context, r *redis.Client, cfg config.Config) (t TaskController)

NewTaskController initializes and returns a new TaskController object.

func (*TaskController) MonitorLastTaskScheduling

func (tc *TaskController) MonitorLastTaskScheduling(tt schemas.TaskType)

func (*TaskController) MonitorNextTaskScheduling

func (tc *TaskController) MonitorNextTaskScheduling(tt schemas.TaskType, duration int)

Jump to

Keyboard shortcuts

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