worker

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package worker provides background task scheduling for the control plane. Workers handle periodic operations like health checks, state reconciliation, garbage collection, and certificate renewal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertRenewer

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

CertRenewer periodically checks for expiring TLS certificates and renews them.

func NewCertRenewer

func NewCertRenewer(network network.Service, events event.Bus, interval time.Duration) *CertRenewer

NewCertRenewer creates a new certificate renewer worker.

func (*CertRenewer) Interval

func (c *CertRenewer) Interval() time.Duration

Interval returns how often the certificate renewer should run.

func (*CertRenewer) Name

func (c *CertRenewer) Name() string

Name returns the worker name.

func (*CertRenewer) Run

func (c *CertRenewer) Run(_ context.Context) error

Run executes one certificate renewal cycle. TODO: implement certificate renewal. List all certificates nearing expiry, attempt renewal via the network service, and publish events for successful renewals or failures.

type GarbageCollector

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

GarbageCollector periodically removes stale data from the store.

func NewGarbageCollector

func NewGarbageCollector(store store.Store, interval time.Duration) *GarbageCollector

NewGarbageCollector creates a new garbage collector worker.

func (*GarbageCollector) Interval

func (g *GarbageCollector) Interval() time.Duration

Interval returns how often the garbage collector should run.

func (*GarbageCollector) Name

func (g *GarbageCollector) Name() string

Name returns the worker name.

func (*GarbageCollector) Run

Run executes one garbage collection cycle. TODO: implement garbage collection. Remove expired deployments, orphaned resources, stale telemetry data, and revoked certificates that exceed their retention period.

type HealthRunner

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

HealthRunner periodically executes health checks for all instances.

func NewHealthRunner

func NewHealthRunner(health health.Service, events event.Bus, interval time.Duration) *HealthRunner

NewHealthRunner creates a new health runner worker.

func (*HealthRunner) Interval

func (h *HealthRunner) Interval() time.Duration

Interval returns how often the health runner should run.

func (*HealthRunner) Name

func (h *HealthRunner) Name() string

Name returns the worker name.

func (*HealthRunner) Run

func (h *HealthRunner) Run(_ context.Context) error

Run executes one health check cycle. TODO: implement health check execution. Iterate over all configured health checks, run each via the health service, and publish events for status changes.

type Reconciler

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

Reconciler compares desired state in the database with actual provider state and corrects any drift.

func NewReconciler

func NewReconciler(instances instance.Store, providers *provider.Registry, events event.Bus, interval time.Duration) *Reconciler

NewReconciler creates a new reconciler worker.

func (*Reconciler) Interval

func (r *Reconciler) Interval() time.Duration

Interval returns how often the reconciler should run.

func (*Reconciler) Name

func (r *Reconciler) Name() string

Name returns the worker name.

func (*Reconciler) Run

func (r *Reconciler) Run(_ context.Context) error

Run executes one reconciliation cycle. TODO: implement reconciliation logic. For each instance in the store, compare the desired state (DB) with the actual state reported by the provider. If drift is detected, issue corrective actions through the provider and publish events for any state changes.

type Scheduler

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

Scheduler manages a set of workers, running each on its configured interval.

func NewScheduler

func NewScheduler() *Scheduler

NewScheduler creates a new scheduler with an empty worker list.

func (*Scheduler) Register

func (s *Scheduler) Register(w Worker)

Register adds a worker to the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) error

Start launches a goroutine for each periodic worker. It returns immediately.

func (*Scheduler) Stop

func (s *Scheduler) Stop(_ context.Context) error

Stop cancels all running workers and waits for them to finish.

type TelemetryCollector

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

TelemetryCollector periodically gathers metrics and resource usage from providers.

func NewTelemetryCollector

func NewTelemetryCollector(telemetry telemetry.Service, providers *provider.Registry, interval time.Duration) *TelemetryCollector

NewTelemetryCollector creates a new telemetry collector worker.

func (*TelemetryCollector) Interval

func (t *TelemetryCollector) Interval() time.Duration

Interval returns how often the telemetry collector should run.

func (*TelemetryCollector) Name

func (t *TelemetryCollector) Name() string

Name returns the worker name.

func (*TelemetryCollector) Run

Run executes one telemetry collection cycle. TODO: implement telemetry collection. Query each registered provider for current resource usage and metrics, then push the data through the telemetry service for storage and aggregation.

type Worker

type Worker interface {
	// Name identifies the worker.
	Name() string

	// Interval returns how often the worker should run.
	// Return 0 for event-driven workers that do not run periodically.
	Interval() time.Duration

	// Run executes one cycle of the worker.
	Run(ctx context.Context) error
}

Worker is a background task that runs periodically.

Jump to

Keyboard shortcuts

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