schedule

package
v1.74.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(ctx context.Context, name string)

Callback is invoked when package state changes.

type Checks

type Checks struct {
	Kubernetes *semver.Constraints              // Kubernetes version constraint (e.g., ">=1.21")
	Deckhouse  *semver.Constraints              // Deckhouse version constraint
	Modules    map[string]dependency.Dependency // Module dependency constraints
}

Checks defines version constraints that must be satisfied for a package to be enabled.

type Option

type Option func(*Scheduler)

func WithBootstrapCondition

func WithBootstrapCondition(cond condition.Condition) Option

func WithDeckhouseVersionGetter

func WithDeckhouseVersionGetter(deckhouseVersionGetter version.Getter) Option

func WithDependencyGetter

func WithDependencyGetter(dependencyGetter dependency.Getter) Option

func WithKubeVersionGetter

func WithKubeVersionGetter(kubeVersionGetter version.Getter) Option

func WithOnDisable

func WithOnDisable(callback Callback) Option

func WithOnEnable

func WithOnEnable(callback Callback) Option

type Package

type Package interface {
	GetName() string
	GetChecks() Checks
}

Package represents a package that can be scheduled for enable/disable based on conditions.

type Scheduler

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

Scheduler manages package enable/disable state based on version constraints and conditions. It evaluates checkers for each package and invokes callbacks when state changes.

Thread-safety: Uses mutex for nodes map and atomic.Bool for pause state.

func NewScheduler

func NewScheduler(opts ...Option) *Scheduler

NewScheduler creates a new Scheduler instance. The scheduler starts in paused state and must be explicitly resumed.

func (*Scheduler) Add

func (s *Scheduler) Add(pkg Package)

Add registers a package with the scheduler and creates checkers based on its constraints. If scheduler is not paused and checks pass, onEnable callback is invoked immediately.

Checker evaluation order:

  1. Kubernetes version
  2. Deckhouse version
  3. Bootstrap condition

Thread-safety: Acquires mutex to add node, releases before invoking callbacks to avoid deadlock.

func (*Scheduler) Pause

func (s *Scheduler) Pause()

Pause prevents any state changes from being processed. Packages can still be added/removed, but no callbacks will be invoked.

func (*Scheduler) Remove

func (s *Scheduler) Remove(pkg string)

Remove unregisters a package from the scheduler. No callback is invoked - the package is simply removed from tracking.

func (*Scheduler) Resume

func (s *Scheduler) Resume()

Resume enables state change processing and re-evaluates all packages. For each package whose state changed, the appropriate callback is invoked.

func (*Scheduler) State

func (s *Scheduler) State(name string) State

State returns the current enable/disable state for a package. Returns State{Enabled: false} if package is not registered.

type State

type State struct {
	Enabled bool   `json:"enabled" yaml:"enabled"`                   // Whether package is enabled
	Reason  string `json:"reason,omitempty" yaml:"reason,omitempty"` // Reason for current state (typically set when disabled)
}

State represents the current enable/disable state of a package.

Directories

Path Synopsis
dependency
Package dependency provides a checker for validating package dependencies.
Package dependency provides a checker for validating package dependencies.

Jump to

Keyboard shortcuts

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