spoterm

package module
v0.0.0-...-ba1f8b2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2015 License: MIT Imports: 5 Imported by: 0

README

spoterm

spoterm provides advance notification of EC2 spot instance termination

GoDoc

BuildStatus

Documentation

Overview

Package spoterm provides advance notification of EC2 spot instance termination, allowing an instance to clean up state before termination.

For documentation of spot termination, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SpotermNotify

func SpotermNotify() (<-chan time.Time, error)

SpotermNotify returns a channel of time.Time or an error. When the spot termination-time is set in instance metadata, the time is sent on the channel. If an unrecoverable error occurs after initialization, the channel is closed. The termination-time is polled every 5 seconds, giving a minimum of 115 seconds from notification to termination. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html

Example
ch, err := SpotermNotify()
if err != nil {
	// handle error
	// an error will occur if run on a non-ec2 instance
	log.Fatal(err)
}
go func() {
	if t, ok := <-ch; ok {
		// received termination-time
		// run cleanup actions here
		log.Printf("the instance will be terminated at %v", t)

	} else {
		log.Printf("SpotermNotify channel closed due to error")
	}
}()
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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