executor

package
v1.6.5 Latest Latest
Warning

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

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

Documentation

Overview

Package executor defines the executor interface and registry.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = NewRegistry()

DefaultRegistry is the global executor registry.

Functions

func Register

func Register(executor Executor)

Register adds an executor to the default registry.

Types

type AWSConnectorConfig

type AWSConnectorConfig = awsutil.AWSConnectorConfig

AWSConnectorConfig holds AWS connector settings.

type ConnectorConfig

type ConnectorConfig struct {
	// AWS holds AWS-specific configuration.
	AWS *AWSConnectorConfig
	// K8S holds Kubernetes-specific configuration.
	K8S *K8SConnectorConfig
}

ConnectorConfig holds resolved connector settings.

type ErrorList added in v1.6.2

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

ErrorList is a thread-safe accumulator for errors. It is useful when multiple goroutines may encounter errors and the caller wants to collect them for later reporting instead of failing fast.

func (*ErrorList) Add added in v1.6.2

func (e *ErrorList) Add(err error)

Add appends an error to the list. Nil errors are ignored.

func (*ErrorList) Addf added in v1.6.2

func (e *ErrorList) Addf(format string, args ...interface{})

Addf appends a formatted error to the list.

func (*ErrorList) Join added in v1.6.2

func (e *ErrorList) Join(sep string) string

Join returns all accumulated error messages joined by the given separator.

func (*ErrorList) Len added in v1.6.2

func (e *ErrorList) Len() int

Len returns the number of accumulated errors.

type Executor

type Executor interface {
	// Type returns the executor type identifier.
	Type() string

	// Validate validates the executor spec.
	Validate(spec Spec) error

	// Shutdown performs the hibernation operation.
	// Restore data should be saved incrementally via spec.ReportStateCallback.
	// Returns a Result with a summary message on success.
	Shutdown(ctx context.Context, log logr.Logger, spec Spec) (*Result, error)

	// WakeUp performs the restore operation using saved restore data.
	// Returns a Result with a summary message on success.
	WakeUp(ctx context.Context, log logr.Logger, spec Spec, restore RestoreData) (*Result, error)
}

Executor is the interface that all executors must implement.

func Get

func Get(executorType string) (Executor, bool)

Get retrieves an executor from the default registry.

type K8SConnectorConfig

type K8SConnectorConfig = k8sutil.K8SConnectorConfig

K8SConnectorConfig holds Kubernetes connector settings.

type Registry

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

Registry holds registered executors.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new executor registry.

func (*Registry) Get

func (r *Registry) Get(executorType string) (Executor, bool)

Get retrieves an executor by type.

func (*Registry) List

func (r *Registry) List() []string

List returns all registered executor types.

func (*Registry) Register

func (r *Registry) Register(executor Executor)

Register adds an executor to the registry.

type ReportStateCallback added in v1.6.0

type ReportStateCallback func(key string, value interface{}) error

ReportStateCallback is a callback for incremental restore data persistence. Executors call this after each successful sub-resource operation to save restore data incrementally, preventing data loss on partial failures. Any data reported through this callback is inherently "live" — the executor just captured it from the actual cloud/cluster API.

Parameters:

key: Resource-specific key (e.g., instanceID, nodeGroupName)
value: Resource state (will be JSON-marshaled by callback implementation)

type RestoreData

type RestoreData struct {
	// Type of the executor that produced this data.
	Type string `json:"type"`

	// Data is a unified map of resource key → resource state (as JSON).
	// Keys are executor-specific:
	// - EC2: instanceID (e.g., "i-1234567890abcdef0")
	// - EKS: nodeGroupName (e.g., "ng-1")
	// - Karpenter: nodePoolName (e.g., "default")
	// - WorkloadScaler: namespace/kind/name (e.g., "team-a/Deployment/api")
	// - RDS: instanceID or clusterID with prefix (e.g., "instance:my-db", "cluster:my-cluster")
	// - Noop: operation ID (e.g., "noop-12345")
	Data map[string]json.RawMessage `json:"data"`

	// IsLive indicates whether data was captured from actual resource state via API (true)
	// or is cached/unknown state (false). When true, hibernator has direct knowledge of the
	// resource state from a fresh API call. When false, the data may be stale or from an
	// incomplete lifecycle. High-quality data (IsLive=true) is preserved over low-quality
	// data (IsLive=false) during save operations.
	IsLive bool `json:"isLive"`
}

RestoreData holds restore metadata produced by Shutdown.

type Result added in v1.6.0

type Result struct {
	// Message is a human-readable summary of what the executor did.
	// For successful operations, this describes the action taken (e.g., "scaled 3 node groups to zero").
	// For failed operations, the error message is used instead.
	Message string

	// ElapsedMs is the wall-clock execution time in milliseconds.
	// This field is populated by the runner after the executor returns;
	// executor implementations should leave it at zero.
	ElapsedMs int64
}

Result holds the outcome of an executor operation.

type Spec

type Spec struct {
	// TargetName is the name of the target.
	TargetName string
	// TargetType is the type of the target (eks, rds, ec2).
	TargetType string
	// Parameters is the executor-specific configuration.
	Parameters json.RawMessage
	// ConnectorConfig holds resolved connector configuration.
	ConnectorConfig ConnectorConfig
	// ReportStateCallback is an optional callback for incremental persistence.
	// If provided, executors should call this after each successful sub-resource
	// operation to enable partial-success data preservation.
	ReportStateCallback ReportStateCallback
}

Spec holds target execution parameters.

Directories

Path Synopsis
ec2
Package ec2 implements the EC2 executor for hibernating EC2 instances.
Package ec2 implements the EC2 executor for hibernating EC2 instances.
eks
Package eks implements the EKS executor for hibernating EKS Managed Node Groups.
Package eks implements the EKS executor for hibernating EKS Managed Node Groups.
Package noop implements a no-operation executor for testing hibernation workflows without external dependencies.
Package noop implements a no-operation executor for testing hibernation workflows without external dependencies.
rds
Package rds implements the RDS executor for hibernating RDS instances.
Package rds implements the RDS executor for hibernating RDS instances.

Jump to

Keyboard shortcuts

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