lifecycle

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultQueueCapacity = 100
	MinJobRetention      = time.Hour
	MaxTerminalJobs      = 1000
	CleanupInterval      = 5 * time.Minute
)

Variables

View Source
var (
	ErrBlocked            = errors.New("operations are blocked")
	ErrClosing            = errors.New("lifecycle controller is shutting down")
	ErrInvalidRequest     = errors.New("invalid lifecycle request")
	ErrJobNotFound        = errors.New("job not found")
	ErrQueueFull          = errors.New("job queue is full")
	ErrShutdownInProgress = errors.New("shutdown operation is in progress")
)

Functions

This section is empty.

Types

type Container

type Container struct {
	ID          string
	Name        string
	Labels      map[string]string
	Running     bool
	StopTimeout *time.Duration
}

type ContainerResult

type ContainerResult struct {
	Container string  `json:"container"`
	Outcome   Outcome `json:"outcome"`
	Reason    Reason  `json:"reason,omitempty"`
	Error     string  `json:"error,omitempty"`
}

type ContainerState

type ContainerState struct {
	Running     bool
	Healthcheck Healthcheck
	Health      Health
}

type Controller

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

func NewController

func NewController(containerRuntime Runtime, logger *logger.Logger) *Controller

func (*Controller) Block

func (c *Controller) Block(ctx context.Context, duration time.Duration) error

func (*Controller) Job

func (c *Controller) Job(ctx context.Context, id string) (JobSnapshot, error)

func (*Controller) Ready

func (c *Controller) Ready(ctx context.Context) error

func (*Controller) Shutdown

func (c *Controller) Shutdown(ctx context.Context) error

func (*Controller) Submit

func (c *Controller) Submit(ctx context.Context, request Request) (JobSnapshot, error)

func (*Controller) Unblock

func (c *Controller) Unblock(ctx context.Context) error

type ExecutionResult

type ExecutionResult struct {
	Outcomes []ContainerResult
	Err      error
}

type Health

type Health string
const (
	HealthNone      Health = "none"
	HealthStarting  Health = "starting"
	HealthHealthy   Health = "healthy"
	HealthUnhealthy Health = "unhealthy"
)

type Healthcheck

type Healthcheck string
const (
	HealthcheckNone       Healthcheck = "none"
	HealthcheckDisabled   Healthcheck = "disabled"
	HealthcheckConfigured Healthcheck = "configured"
)

type Intent

type Intent string
const (
	IntentNormal   Intent = ""
	IntentShutdown Intent = "shutdown"
)

type JobSnapshot

type JobSnapshot struct {
	ID        string
	Operation Operation
	Status    Status
	CreatedAt time.Time
	StartedAt time.Time
	EndedAt   time.Time
	Timeout   time.Duration
	Ignore    []string
	Started   []string
	Stopped   []string
	Skipped   []string
	Failed    []string
	Outcomes  []ContainerResult
	Error     string
}

type Operation

type Operation string
const (
	OperationStart Operation = "start"
	OperationStop  Operation = "stop"
)

type Outcome

type Outcome string
const (
	OutcomeChanged   Outcome = "changed"
	OutcomeUnchanged Outcome = "unchanged"
	OutcomeIgnored   Outcome = "ignored"
	OutcomeProtected Outcome = "protected"
	OutcomeBlocked   Outcome = "blocked"
	OutcomeFailed    Outcome = "failed"
	OutcomeCanceled  Outcome = "canceled"
)

type Reason

type Reason string
const (
	ReasonAlreadyRunning      Reason = "already_running"
	ReasonAlreadyStopped      Reason = "already_stopped"
	ReasonRequestedIgnore     Reason = "requested_ignore"
	ReasonRequiredByIgnored   Reason = "required_by_ignored_container"
	ReasonDependencyIgnored   Reason = "dependency_ignored_unavailable"
	ReasonMissingDependency   Reason = "missing_dependency"
	ReasonDependencyFailed    Reason = "dependency_failed"
	ReasonDependencyUnhealthy Reason = "dependency_unhealthy"
	ReasonOperationFailed     Reason = "operation_failed"
	ReasonCanceledByShutdown  Reason = "canceled_by_shutdown"
	ReasonDeadlineExceeded    Reason = "deadline_exceeded"
	ReasonDependencyCycle     Reason = "dependency_cycle"
)

type Request

type Request struct {
	Operation Operation
	Intent    Intent
	Timeout   time.Duration
	Ignore    []string
}

type Runtime

type Runtime interface {
	ListContainers(context.Context) ([]Container, error)
	InspectContainer(context.Context, string) (ContainerState, error)
	StartContainer(context.Context, string) error
	StopContainer(context.Context, string, time.Duration) error
	Ping(context.Context) error
}

type Status

type Status string
const (
	StatusPending   Status = "pending"
	StatusRunning   Status = "running"
	StatusCompleted Status = "completed"
	StatusFailed    Status = "failed"
)

Jump to

Keyboard shortcuts

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