hive

package
v1.17.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

View Source
const (
	LabelModuleId  = "module_id"
	LabelOperation = "op"
)

Variables

View Source
var (
	ShutdownWithError = upstream.ShutdownWithError
)

Functions

func AddConfigOverride

func AddConfigOverride[Cfg cell.Flagger](h *Hive, override func(*Cfg))

Types

type Feature

type Feature string

type FeatureLifecycle

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

func NewFeatureLifecycle

func NewFeatureLifecycle() *FeatureLifecycle

func (*FeatureLifecycle) Append

func (fl *FeatureLifecycle) Append(f Feature, h cell.Hook) error

Append adds a hook to the feature hooks, marking the feature as not running. It returns an error if the feature is already running.

func (*FeatureLifecycle) IsRunning

func (fl *FeatureLifecycle) IsRunning(f Feature) bool

IsRunning checks if a feature is currently running. It returns true if the feature exists in status map and its status is true, and false otherwise.

func (*FeatureLifecycle) List

func (fl *FeatureLifecycle) List() []Feature

List returns a list of all features registered

func (*FeatureLifecycle) Start

func (fl *FeatureLifecycle) Start(f Feature, c context.Context, l *slog.Logger) error

Start attempts to start a feature by executing its associated hooks. It returns an error if the feature is already running or if any hook fails to start.

func (*FeatureLifecycle) Stop

Stop attempts to stop a feature by stopping its associated hooks. It returns an error if the feature is already stopped. If any hook encounters an error during stopping it aggregates into return error

type FeatureLifecycleInterface

type FeatureLifecycleInterface interface {
	Append(Feature, cell.Hook) error
	Start(Feature, context.Context, *slog.Logger) error
	Stop(Feature, context.Context, *slog.Logger) error

	IsRunning(Feature) bool
	List() []Feature
}

type Hive

type Hive = upstream.Hive

func New

func New(cells ...cell.Cell) *Hive

New wraps the hive.New to create a hive with defaults used by cilium-agent. pkg/hive should eventually go away and this code should live in e.g. daemon/cmd or operator/cmd.

type OnDemand

type OnDemand[Resource any] interface {
	// Acquire a resource. On the first call to Acquire() the underlying
	// resource is started with the provided context that aborts the start
	// if the context is cancelled. On failure to start the resulting error
	// is returned.
	Acquire(context.Context) (Resource, error)

	// Release a resource. When the last acquired reference to the resource
	// is released the resource is stopped. If stopping the resource fails
	// the error is returned.
	Release(resource Resource) error
}

OnDemand provides access to a resource on-demand. On first call to Acquire() the resource is started (cell.Lifecycle.Start). If the starting of the resource fails Acquire() returns the error from Start(). When all references are Release()'d the resource is stopped (cell.Lifecycle.Stop), and again failure from Stop() is returned.

func NewOnDemand

func NewOnDemand[Resource any](log *slog.Logger, resource Resource, hook cell.HookInterface) OnDemand[Resource]

NewOnDemand wraps a resource that will be started and stopped on-demand. The resource and the lifecycle hooks are provided separately, but can of course be the same thing. They're separate to support the use-case where the resource is a state object (e.g. StateDB table) and the hook is a job group that populates the object.

func NewStaticOnDemand

func NewStaticOnDemand[Resource any](resource Resource) OnDemand[Resource]

NewStaticOnDemand creates an on-demand resource that is "static", i.e. always running and not started or stopped.

type Options added in v1.16.0

type Options = upstream.Options

type ReconcilerMetrics added in v1.16.0

type ReconcilerMetrics struct {
	ReconciliationCount         metric.Vec[metric.Counter]
	ReconciliationDuration      metric.Vec[metric.Observer]
	ReconciliationTotalErrors   metric.Vec[metric.Counter]
	ReconciliationCurrentErrors metric.Vec[metric.Gauge]

	PruneCount       metric.Vec[metric.Counter]
	PruneTotalErrors metric.Vec[metric.Counter]
	PruneDuration    metric.Vec[metric.Observer]
}

func NewStateDBReconcilerMetrics added in v1.16.0

func NewStateDBReconcilerMetrics() (ReconcilerMetrics, reconciler.Metrics)

type Shutdowner

type Shutdowner = upstream.Shutdowner

type StateDBMetrics added in v1.16.0

type StateDBMetrics struct {
	// How long a read transaction was held.
	WriteTxnDuration metric.Vec[metric.Observer]
	// How long it took to acquire a write transaction for all tables.
	WriteTxnAcquisition metric.Vec[metric.Observer]
	// How long writers were blocked while waiting to acquire a write transaction for a specific table.
	TableContention metric.Vec[metric.Gauge]
	// The amount of objects in a given table.
	TableObjectCount metric.Vec[metric.Gauge]
	// The current revision of a given table.
	TableRevision metric.Vec[metric.Gauge]
	// The amount of delete trackers for a given table.
	TableDeleteTrackerCount metric.Vec[metric.Gauge]
	// The amount of objects in the graveyard for a given table.
	TableGraveyardObjectCount metric.Vec[metric.Gauge]
	// The lowest revision of a given table that has been processed by the graveyard garbage collector.
	TableGraveyardLowWatermark metric.Vec[metric.Gauge]
	// The time it took to clean the graveyard for a given table.
	TableGraveyardCleaningDuration metric.Vec[metric.Observer]
}

func NewStateDBMetrics added in v1.16.0

func NewStateDBMetrics() (StateDBMetrics, statedb.Metrics)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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