statuses

package
v0.6.17 Latest Latest
Warning

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

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

Documentation

Overview

Package statuses provides an interface and implementation for managing workload statuses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NoopStatusManager added in v0.6.17

type NoopStatusManager struct{}

NoopStatusManager is a no-op implementation of StatusManager that does nothing. All methods return zero values or empty results without performing any operations.

func (*NoopStatusManager) DeleteWorkloadStatus added in v0.6.17

func (*NoopStatusManager) DeleteWorkloadStatus(_ context.Context, _ string) error

DeleteWorkloadStatus does nothing and returns nil.

func (*NoopStatusManager) GetWorkload added in v0.6.17

func (*NoopStatusManager) GetWorkload(_ context.Context, _ string) (core.Workload, error)

GetWorkload returns an empty workload and nil error.

func (*NoopStatusManager) GetWorkloadPID added in v0.6.17

func (*NoopStatusManager) GetWorkloadPID(_ context.Context, _ string) (int, error)

GetWorkloadPID returns 0 and nil error.

func (*NoopStatusManager) ListWorkloads added in v0.6.17

func (*NoopStatusManager) ListWorkloads(_ context.Context, _ bool, _ []string) ([]core.Workload, error)

ListWorkloads returns an empty slice of workloads.

func (*NoopStatusManager) ResetWorkloadPID added in v0.6.17

func (*NoopStatusManager) ResetWorkloadPID(_ context.Context, _ string) error

ResetWorkloadPID does nothing and returns nil.

func (*NoopStatusManager) SetWorkloadPID added in v0.6.17

func (*NoopStatusManager) SetWorkloadPID(_ context.Context, _ string, _ int) error

SetWorkloadPID does nothing and returns nil.

func (*NoopStatusManager) SetWorkloadStatus added in v0.6.17

func (*NoopStatusManager) SetWorkloadStatus(_ context.Context, _ string, _ rt.WorkloadStatus, _ string) error

SetWorkloadStatus does nothing and returns nil.

type StatusManager

type StatusManager interface {
	// GetWorkload retrieves details of a workload by its name.
	GetWorkload(ctx context.Context, workloadName string) (core.Workload, error)
	// ListWorkloads returns details of all workloads.
	ListWorkloads(ctx context.Context, listAll bool, labelFilters []string) ([]core.Workload, error)
	// SetWorkloadStatus sets the status of a workload by its name.
	// Note that this does not return errors, but logs them instead.
	// This method will do nothing if the workload does not exist.
	// This method will preserve the PID of the workload if it was previously set.
	SetWorkloadStatus(ctx context.Context, workloadName string, status rt.WorkloadStatus, contextMsg string) error
	// DeleteWorkloadStatus removes the status of a workload by its name.
	DeleteWorkloadStatus(ctx context.Context, workloadName string) error
	// SetWorkloadPID sets the PID of a workload by its name.
	// This method will do nothing if the workload does not exist.
	SetWorkloadPID(ctx context.Context, workloadName string, pid int) error
	// ResetWorkloadPID resets the PID of a workload to 0.
	// This method will do nothing if the workload does not exist.
	ResetWorkloadPID(ctx context.Context, workloadName string) error
	// GetWorkloadPID retrieves the PID of a workload by its name.
	// Returns 0 if the workload does not exist or if PID is not available.
	GetWorkloadPID(ctx context.Context, workloadName string) (int, error)
}

StatusManager is an interface for fetching and retrieving workload statuses.

func NewFileStatusManager

func NewFileStatusManager(runtime rt.Runtime) (StatusManager, error)

NewFileStatusManager creates a new file-based StatusManager. Status files will be stored in the XDG data directory under "statuses/".

func NewNoopStatusManager added in v0.6.17

func NewNoopStatusManager() StatusManager

NewNoopStatusManager creates a new NoopStatusManager instance.

func NewStatusManager

func NewStatusManager(runtime rt.Runtime) (StatusManager, error)

NewStatusManager creates a new status manager instance using the appropriate implementation based on the runtime environment. If running in Kubernetes, it returns the runtime-based implementation. Otherwise, it returns the file-based implementation.

func NewStatusManagerFromRuntime

func NewStatusManagerFromRuntime(runtime rt.Runtime) StatusManager

NewStatusManagerFromRuntime creates a new instance of StatusManager from an existing runtime.

func NewStatusManagerWithEnv added in v0.2.13

func NewStatusManagerWithEnv(runtime rt.Runtime, envReader env.Reader) (StatusManager, error)

NewStatusManagerWithEnv creates a new status manager instance using the provided environment reader. This allows for dependency injection of environment variable access for testing.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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