ec2

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: 10 Imported by: 0

Documentation

Overview

Package ec2 provides an interface to EC2 instances, that are polled from the API. It manages a local cache, which is updated periodically.

Index

Constants

View Source
const (
	InstanceStatePending      = "pending"
	InstanceStateRunning      = "running"
	InstanceStateTerminated   = "terminated"
	InstanceStateShuttingDown = "shutting-down"
)

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 EC2 Instances 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 EC2 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"`
	InstanceName      string     `logfield:"instance-name"`
	NodeName          string     `logfield:"node-name,omitempty"`
	InstanceType      string     `logfield:"instance-type"`
	AvailabilityZone  string     `logfield:"availability-zone"`
	InstanceLifecycle string     `logfield:"ec2-instance-lifecycle"`
	State             string     `logfield:"ec2-instance-state"`
	LaunchTime        time.Time  `logfield:"ec2-launch-time"`
	TerminationTime   *time.Time `logfield:"ec2-termination-time,omitempty"`
}

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.

func (Instance) IsRunning

func (i Instance) IsRunning() bool

Jump to

Keyboard shortcuts

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