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
- type AwsManager
- func (awsManager *AwsManager) GetName() string
- func (awsManager *AwsManager) OnShutdown(shutdownManager string) error
- func (awsManager *AwsManager) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (awsManager *AwsManager) ShutdownFinish() error
- func (awsManager *AwsManager) ShutdownStart() error
- func (awsManager *AwsManager) Start(gs gracefulshutdown.GSInterface) error
- type AwsManagerConfig
Constants ¶
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.