supervisor

package
v0.0.0-...-38df0df Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ShutdownTimeout is max time to wait for all observers to exit
	ShutdownTimeout time.Duration

	// HealthCheckInterval is how often to check observer health
	// Reserved for Phase 2 - not yet enforced
	// Default: 5 seconds
	HealthCheckInterval time.Duration

	// ResourceCheckInterval is how often to check resource usage
	// Reserved for Phase 2 - not yet enforced
	// Default: 1 second
	ResourceCheckInterval time.Duration
}

Config configures supervisor behavior

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default supervisor configuration

type HealthCheckFunc

type HealthCheckFunc func(ctx context.Context) HealthStatus

HealthCheckFunc checks if observer is healthy

type HealthStatus

type HealthStatus string

HealthStatus represents observer health state

const (
	HealthStatusHealthy   HealthStatus = "healthy"   // All good
	HealthStatusDegraded  HealthStatus = "degraded"  // Slow but working
	HealthStatusUnhealthy HealthStatus = "unhealthy" // Needs restart
)

type Option

type Option func(*observerConfig)

Option is a functional option for configuring observer supervision

func WithDependencies

func WithDependencies(deps ...string) Option

WithDependencies configures observer dependencies Reserved for Phase 2 - not yet enforced

func WithHealthCheck

func WithHealthCheck(fn HealthCheckFunc) Option

WithHealthCheck configures observer health check function Reserved for Phase 2 - not yet enforced

func WithOptionalDeps

func WithOptionalDeps(optional bool) Option

WithOptionalDeps marks dependencies as optional (can run in degraded mode) Reserved for Phase 2 - not yet enforced

func WithResourceLimits

func WithResourceLimits(cpuCores float64, memoryBytes uint64) Option

WithResourceLimits configures CPU and memory limits Reserved for Phase 2 - not yet enforced

func WithRestartPolicy

func WithRestartPolicy(maxRestarts int, window time.Duration) Option

WithRestartPolicy configures auto-restart behavior

func WithWorkerScaling

func WithWorkerScaling(min, max int) Option

WithWorkerScaling configures worker pool scaling Reserved for Phase 2 - not yet enforced

type Supervisor

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

Supervisor manages lifecycle of multiple observers

func New

func New(cfg Config, opts ...SupervisorOption) *Supervisor

New creates a new supervisor with given configuration

func (*Supervisor) ObserverNames

func (s *Supervisor) ObserverNames() []string

ObserverNames returns list of registered observer names

func (*Supervisor) Run

func (s *Supervisor) Run(ctx context.Context) error

Run starts supervising all observers and blocks until context is cancelled

func (*Supervisor) SuperviseFunc

func (s *Supervisor) SuperviseFunc(name string, fn func(context.Context) error, opts ...Option)

SuperviseFunc adds an observer function to be supervised

type SupervisorOption

type SupervisorOption func(*Supervisor)

SupervisorOption configures supervisor-level settings

func WithMeter

func WithMeter(meter metric.Meter) SupervisorOption

WithMeter configures OTEL metrics collection

Jump to

Keyboard shortcuts

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