spot

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package spot provides an interface to Spot requests, that are polled from the API. It manages a local cache, which is updated periodically.

Index

Constants

View Source
const (
	StateActive    = "active"
	StateCancelled = "cancelled"
	StateFailed    = "failed"
	StateClosed    = "closed"
)

See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html

View Source
const (
	StatusCodeFulfilled                         = "fulfilled"
	StatusCodeInstanceTerminatedByUser          = "instance-terminated-by-user"
	StatusCodeMarkedForTermination              = "marked-for-termination"
	StatusCodeMarkedForStop                     = "marked-for-stop"
	StatusCodeRequestCanceledAndInstanceRunning = "request-canceled-and-instance-running"
)

See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-request-status.html

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Run executes the EC2 API poller. It will update the instance cache
	// periodically.
	Run(context.Context) error

	// List returns all Spot requests that are currently in the cache. Those
	// instance cache will be updated in the background.
	List() []Instance

	// SignalEmitter gets triggered every time the cache changes. See syncutil
	// package for more information.
	SignalEmitter() *syncutil.SignalEmitter

	// Healthy indicates whether the background job is running correctly.
	Healthy() bool
}

Client is an interface to Spot request data.

func New

func New(conf *aws.Config, refresh time.Duration) Client

New creates a new client for the EC2 API. It needs to be started with Run so it actually reads messages. See Client interface for more information.

type Instance

type Instance struct {
	InstanceID       string    `logfield:"instance-id,omitempty"`
	RequestID        string    `logfield:"spot-request-id"`
	CreateTime       time.Time `logfield:"spot-create-time"`
	State            string    `logfield:"spot-state"`
	StatusCode       string    `logfield:"spot-status-code"`
	StatusUpdateTime time.Time `logfield:"spot-status-update-time"`
}

Instance is the instance-related data that is retrieved via API.

func (Instance) Changed

func (i Instance) Changed(old Instance) bool

Changed returns true, if relevant fields of the instance changed.

Jump to

Keyboard shortcuts

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