compute

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 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) DescribeInstances

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

DescribeInstances describes instances.

func (*Compute) ModifyInstance

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

ModifyInstance modifies an instance.

func (*Compute) RebootInstances

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

RebootInstances reboots running instances.

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) 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.

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