compute

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package compute provides a portable compute API with cross-cutting concerns.

Index

Constants

View Source
const (
	StatePending      = "pending"
	StateRunning      = "running"
	StateStopping     = "stopping"
	StateStopped      = "stopped"
	StateShuttingDown = "shutting-down"
	StateTerminated   = "terminated"
	StateRestarting   = "restarting"
)

VM states.

Variables

This section is empty.

Functions

func VMTransitions

func VMTransitions() []statemachine.Transition

VMTransitions returns the legal VM state transitions.

Types

type Compute

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

Compute is the portable compute type wrapping a driver with cross-cutting concerns.

func NewCompute

func NewCompute(d driver.Compute, opts ...Option) *Compute

NewCompute creates a new portable Compute wrapping the given driver.

func (*Compute) CancelSpotRequests added in v1.2.0

func (c *Compute) CancelSpotRequests(ctx context.Context, requestIDs []string) error

CancelSpotRequests cancels spot/preemptible instance requests.

func (*Compute) CreateAutoScalingGroup added in v1.2.0

func (c *Compute) CreateAutoScalingGroup(
	ctx context.Context, config driver.AutoScalingGroupConfig,
) (*driver.AutoScalingGroup, error)

CreateAutoScalingGroup creates an auto-scaling group.

func (*Compute) CreateLaunchTemplate added in v1.2.0

func (c *Compute) CreateLaunchTemplate(
	ctx context.Context, config driver.LaunchTemplateConfig,
) (*driver.LaunchTemplate, error)

CreateLaunchTemplate creates a launch template.

func (*Compute) DeleteAutoScalingGroup added in v1.2.0

func (c *Compute) DeleteAutoScalingGroup(ctx context.Context, name string, forceDelete bool) error

DeleteAutoScalingGroup deletes an auto-scaling group.

func (*Compute) DeleteLaunchTemplate added in v1.2.0

func (c *Compute) DeleteLaunchTemplate(ctx context.Context, name string) error

DeleteLaunchTemplate deletes a launch template.

func (*Compute) DeleteScalingPolicy added in v1.2.0

func (c *Compute) DeleteScalingPolicy(ctx context.Context, asgName, policyName string) error

DeleteScalingPolicy removes a scaling policy.

func (*Compute) DescribeInstances

func (c *Compute) DescribeInstances(ctx context.Context, instanceIDs []string, filters []driver.DescribeFilter) ([]driver.Instance, error)

DescribeInstances describes instances.

func (*Compute) DescribeSpotRequests added in v1.2.0

func (c *Compute) DescribeSpotRequests(
	ctx context.Context, requestIDs []string,
) ([]driver.SpotInstanceRequest, error)

DescribeSpotRequests describes spot/preemptible instance requests.

func (*Compute) ExecuteScalingPolicy added in v1.2.0

func (c *Compute) ExecuteScalingPolicy(ctx context.Context, asgName, policyName string) error

ExecuteScalingPolicy executes a scaling policy.

func (*Compute) GetAutoScalingGroup added in v1.2.0

func (c *Compute) GetAutoScalingGroup(ctx context.Context, name string) (*driver.AutoScalingGroup, error)

GetAutoScalingGroup returns an auto-scaling group.

func (*Compute) GetLaunchTemplate added in v1.2.0

func (c *Compute) GetLaunchTemplate(ctx context.Context, name string) (*driver.LaunchTemplate, error)

GetLaunchTemplate returns a launch template.

func (*Compute) ListAutoScalingGroups added in v1.2.0

func (c *Compute) ListAutoScalingGroups(ctx context.Context) ([]driver.AutoScalingGroup, error)

ListAutoScalingGroups lists all auto-scaling groups.

func (*Compute) ListLaunchTemplates added in v1.2.0

func (c *Compute) ListLaunchTemplates(ctx context.Context) ([]driver.LaunchTemplate, error)

ListLaunchTemplates lists all launch templates.

func (*Compute) ModifyInstance

func (c *Compute) ModifyInstance(ctx context.Context, instanceID string, input driver.ModifyInstanceInput) error

ModifyInstance modifies an instance.

func (*Compute) PutScalingPolicy added in v1.2.0

func (c *Compute) PutScalingPolicy(ctx context.Context, policy driver.ScalingPolicy) error

PutScalingPolicy attaches a scaling policy to an auto-scaling group.

func (*Compute) RebootInstances

func (c *Compute) RebootInstances(ctx context.Context, instanceIDs []string) error

RebootInstances reboots running instances.

func (*Compute) RequestSpotInstances added in v1.2.0

func (c *Compute) RequestSpotInstances(
	ctx context.Context, config driver.SpotRequestConfig,
) ([]driver.SpotInstanceRequest, error)

RequestSpotInstances creates spot/preemptible instance requests.

func (*Compute) RunInstances

func (c *Compute) RunInstances(ctx context.Context, config driver.InstanceConfig, count int) ([]driver.Instance, error)

RunInstances creates new VM instances.

func (*Compute) SetDesiredCapacity added in v1.2.0

func (c *Compute) SetDesiredCapacity(ctx context.Context, name string, desired int) error

SetDesiredCapacity sets the desired capacity of an auto-scaling group.

func (*Compute) StartInstances

func (c *Compute) StartInstances(ctx context.Context, instanceIDs []string) error

StartInstances starts stopped instances.

func (*Compute) StopInstances

func (c *Compute) StopInstances(ctx context.Context, instanceIDs []string) error

StopInstances stops running instances.

func (*Compute) TerminateInstances

func (c *Compute) TerminateInstances(ctx context.Context, instanceIDs []string) error

TerminateInstances terminates instances.

func (*Compute) UpdateAutoScalingGroup added in v1.2.0

func (c *Compute) UpdateAutoScalingGroup(ctx context.Context, name string, desired, minSize, maxSize int) error

UpdateAutoScalingGroup updates an auto-scaling group.

type Option

type Option func(*Compute)

Option configures a portable Compute.

func WithErrorInjection

func WithErrorInjection(i *inject.Injector) Option

WithErrorInjection sets the error injector.

func WithLatency

func WithLatency(d time.Duration) Option

WithLatency sets simulated latency.

func WithMetrics

func WithMetrics(m *metrics.Collector) Option

WithMetrics sets the metrics collector.

func WithRateLimiter

func WithRateLimiter(l *ratelimit.Limiter) Option

WithRateLimiter sets the rate limiter.

func WithRecorder

func WithRecorder(r *recorder.Recorder) Option

WithRecorder sets the recorder.

Directories

Path Synopsis
Package driver defines the interface for compute service implementations.
Package driver defines the interface for compute service implementations.

Jump to

Keyboard shortcuts

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