asg

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

Documentation

Overview

Package asg provides an interface to ASG Lifecycle Hooks, that are delivered via SQS. It manages a local cache, which is filled from SQS messages. The instance lifecycle can be completed, so the ASG can continue to terminate an instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Run executes the SQS message listener. It will update the instance cache
	// based on SQS Messages. It will poll all messages from the ASG Lifecycle
	// Hook and will keep them inflight until the instance actually disapeared.
	Run(ctx context.Context) error

	// List returns all EC2 Instances that are currently in the cache. Those
	// instance cache will be updated in the background, based on SQS Messages.
	List() []Instance

	// Complete finishes the ASG Lifecycle Hook Action with "CONTINUE".
	Complete(ctx context.Context, id string) error

	// Delete deletes the message from SQS.
	Delete(ctx context.Context, id string) error

	// 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 ASG Lifecycle Hooks.

func New

func New(ctx context.Context, conf *aws.Config, queueName string) (Client, error)

New creates a new client for ASG Lifecycle Hooks that are delivered via SQS. It needs to be started with Run so it actually reads messages. See Client interface for more information.

type Instance

type Instance struct {
	// ID is the EC2 Instance ID
	ID string `logfield:"instance-id,omitempty"`

	// TriggeredAt is the thime then the shutdown was triggered.
	TriggeredAt time.Time `logfield:"lifecycle-triggered-at"`

	// Completed indicates that Complete() was called.
	Completed bool `logfield:"lifecycle-completed"`

	// Deleted indicates that Delete() was called.
	Deleted bool `logfield:"lifecycle-deleted"`
}

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

Jump to

Keyboard shortcuts

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