awsmanager

package
v0.0.0-...-3ceaa2d Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

AwsManager provides a listener for a message on SQS queue from the Autoscaler requesting instance termination. If http port is specified, it can forward received message to correct instance via http. It handles sending periodic calls to RecordLifecycleActionHeartbeat and after all callbacks finish a call to CompleteLifecycleAction.

Index

Constants

View Source
const (
	Name = "AwsManager"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AwsManager

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

AwsManager implements ShutdownManager interface that is added to GracefulShutdown. Initialize with NewAwsManager.

func NewAwsManager

func NewAwsManager(awsManagerConfig *AwsManagerConfig) *AwsManager

NewAwsManager initializes the AwsManager. See AwsManagerConfig for configuration options.

func (*AwsManager) GetName

func (awsManager *AwsManager) GetName() string

GetName returns name of this ShutdownManager.

func (*AwsManager) OnShutdown

func (awsManager *AwsManager) OnShutdown(shutdownManager string) error

OnShutdown closes http server on shutdown

func (*AwsManager) ServeHTTP

func (awsManager *AwsManager) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is used for receiving messages over http.

func (*AwsManager) ShutdownFinish

func (awsManager *AwsManager) ShutdownFinish() error

ShutdownFinish first stops the ticker for sending heartbeats, then calls aws api CompleteLifecycleAction.

func (*AwsManager) ShutdownStart

func (awsManager *AwsManager) ShutdownStart() error

ShutdownStart starts sending LifecycleActionHeartbeat every PingTime.

func (*AwsManager) Start

func (awsManager *AwsManager) Start(gs gracefulshutdown.GSInterface) error

Start starts listening to sqs queue and http for termination messages. Will return error if aws metadata is not available or if invalid sqs queueName is given.

type AwsManagerConfig

type AwsManagerConfig struct {
	// Credentials can be nil if credentials are set in ~/.aws/credntials,
	// otherwise see aws-sdk-go documentation.
	Credentials *credentials.Credentials

	// Name of sqs queue to listen for terminating message. Can be empty
	// to disable listening to sqs.
	SqsQueueName string

	// LifecycleHookName is name of the lifecycleHook that will be listened for.
	LifecycleHookName string

	// PingTime is period for sending RecordLifecycleActionHeartbeats.
	// Default is 15 minutes.
	PingTime time.Duration

	// Port on which to listen for terminating messages over http.
	// If 0, http is disabled.
	Port uint16

	// BackOff is time for backup when retrying http listener and http forward
	BackOff float64

	// NumServeRetries is number of retries for http listener
	// -1 for no retries, 0 is default value
	NumServeRetries int

	// NumForwardRetries is number of retries for http forward
	// -1 for no retries, 0 is default value
	NumForwardRetries int

	// Region and InstanceId are optional. If empty they get collected from
	// EC2 instance metadata.
	Region     string
	InstanceId string
}

AwsManagerConfig provides configuration options for AwsManager.

Jump to

Keyboard shortcuts

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