dynamiclifecycle

package
v1.18.5 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigKey = "dynamic-lifecycle-config"
View Source
const TableName = "dynamic-features"

Variables

View Source
var (
	ByFeature = featureIndex.Query
)
View Source
var Cell = cell.Module(
	"dynamic-lifecycle-manager",
	"Groups dynamic feature lifecycles and allows to start and stop dynamically",

	cell.ProvidePrivate(
		newDynamicFeatureTable,
		newOps,
	),

	cell.Provide(
		statedb.RWTable[*DynamicFeature].ToTable,
	),

	cell.Invoke(
		registerWatcher,
		registerReconciler,
	),

	cell.Config(defaultConfig),
)

Cell registers a manager that manages the lifecycle of dynamic features. It allows to add new DynamicFeatureName, Append cell.HookInterface, and Start/Stop lifecycles. A dynamic feature is a group of cell hooks that are grouped together and their lifecycles are managed by the feature manager. The manager uses the DynamicConfig table as the source of truth for enablement. The manager delegates the responsibility of enablement to DynamicFeature StateDB reconciler.

Functions

func WithDynamicLifecycle

func WithDynamicLifecycle(feature DynamicFeatureName, deps []DynamicFeatureName, cells ...cell.Cell) cell.Cell

WithDynamicLifecycle provides a wrapper over the cell.Lifecycle to register DynamicFeature It groups the cells by DynamicFeatureName, providing a DynamicLifecycle for each feature. The hooks are immutable after the hive is initialized and are stored in a stateDB table, see table.go.

Types

type DynamicFeature

type DynamicFeature struct {
	Name          DynamicFeatureName   // DynamicFeature name
	Hooks         []cell.HookInterface // Lifecycle hooks
	Deps          []DynamicFeatureName // DynamicFeature dependencies
	Enabled       bool                 // lifecycle enablement status
	IsRunning     bool                 // lifecycle running status
	Status        reconciler.Status    // reconciliation status
	StartedAt     time.Time            // last lifecycle start time
	StoppedAt     time.Time            // last lifecycle stop time
	StartDuration time.Duration        // last lifecycle start time duration
}

func (*DynamicFeature) Clone

func (tl *DynamicFeature) Clone() *DynamicFeature

Clone returns a shallow copy of the DynamicFeature.

func (*DynamicFeature) TableHeader

func (tl *DynamicFeature) TableHeader() []string

func (*DynamicFeature) TableRow

func (tl *DynamicFeature) TableRow() []string

type DynamicFeatureName

type DynamicFeatureName string

func (DynamicFeatureName) String

func (f DynamicFeatureName) String() string

type FeatureStatus

type FeatureStatus struct {
	Feature DynamicFeatureName
	Enabled bool
}

type Lifecycle

type Lifecycle struct {
	Hooks []cell.HookInterface // Lifecycle hooks
	// contains filtered or unexported fields
}

Lifecycle provides a wrapper over the cell.Lifecycle which only allows appending hooks and performing get on them.

func (*Lifecycle) Append

func (l *Lifecycle) Append(hook cell.HookInterface)

func (*Lifecycle) PrintHooks

func (l *Lifecycle) PrintHooks(w io.Writer)

func (*Lifecycle) Start

func (l *Lifecycle) Start(sl *slog.Logger, _ context.Context) error

func (*Lifecycle) Stop

func (l *Lifecycle) Stop(sl *slog.Logger, _ context.Context) error

Jump to

Keyboard shortcuts

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