Documentation ¶
Overview ¶
Package esu provides wrappers around the AWS-SDK for locating ECS tasks. It can be used for basic service discovery in lieu of using ELBs infront of your containerized tasks.
An assumption is that each task has one canonical container, for example a web server. For multi-container tasks, the canonical container's name should match the service name.
Index ¶
Constants ¶
const DefaultPollFreq = time.Second * 5
DefaultPollFreq specifies how often to check ECS for task changes, under normal operation.
const DefaultVolatilePollFreq = time.Second * 1
DefaultVolatilePollFreq specifies how often to check ECS for task changes, when a task has been noted as being in a pending state or soon to be stopped.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ARN ¶
type ARN struct { Prefix string // Region + Account + Resource Type Resource string Revision string }
ARN contains fields within an ARN used by ECS services.
arn:aws:ecs:region:account-id:task-definition/task-definition-family-name:task-definition-revision-number arn:aws:ecs:region:account-id:container/container-id arn:aws:ecr:region:account-id:repository/repo:tag
type ECSTaskStatus ¶
type ECSTaskStatus string
ECSTaskStatus are the different task states. See http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_life_cycle.html
const ( // ECSTaskStatusRunning indicates the task is running and taking traffic. ECSTaskStatusRunning ECSTaskStatus = "RUNNING" // ECSTaskStatusPending indicates the task has been started. ECSTaskStatusPending ECSTaskStatus = "PENDING" // ECSTaskStatusStopped indicates the task has been stopped. ECSTaskStatusStopped ECSTaskStatus = "STOPPED" )
type TaskFinder ¶
type TaskFinder struct {
// contains filtered or unexported fields
}
TaskFinder provides a wrapper around the AWS-SDK for locating ECS tasks.
func NewTaskFinder ¶
func NewTaskFinder(sess *session.Session, cluster string) *TaskFinder
NewTaskFinder returns a new task finder. It is as thread-safe as the underlying AWS SDK :)
func (*TaskFinder) Services ¶
func (f *TaskFinder) Services() ([]string, error)
Services returns a list of ARNs for all services active on a cluster.
type TaskInfo ¶
type TaskInfo struct { TaskDefinition string DesiredStatus ECSTaskStatus LastStatus ECSTaskStatus StartedAt time.Time Port int EC2InstanceID string PublicDNSName string PublicIPAddress string PrivateDNSName string PrivateIPAddress string }
TaskInfo specifies information about a task running on ECS. A service may have multiple tasks associated with it.
type TaskMonitor ¶
type TaskMonitor struct { Service string PollFreq time.Duration VolatilePollFreq time.Duration OnStatusChange func([]TaskInfo) OnTaskChange func([]TaskInfo) OnError func(error) // contains filtered or unexported fields }
TaskMonitor is
func NewTaskMonitor ¶
func NewTaskMonitor(sess *session.Session, cluster string, service string) *TaskMonitor
NewTaskMonitor returns a new task monitor.
func (*TaskMonitor) AllTasks ¶
func (tm *TaskMonitor) AllTasks() []TaskInfo
AllTasks returns a list of all tasks, including pending and stopped.
func (*TaskMonitor) IsVolatile ¶
func (tm *TaskMonitor) IsVolatile() bool
IsVolatile returns true if any tasks have a desired status that doesn't match last status, or an error was encountered recently.
func (*TaskMonitor) Monitor ¶
func (tm *TaskMonitor) Monitor() chan<- bool
Monitor polls for changes in running tasks, relevant callbacks are executed when changes are detected. There should only be one active Monitor per instance.
func (*TaskMonitor) RunningTasks ¶
func (tm *TaskMonitor) RunningTasks() []TaskInfo
RunningTasks returns a list of currently running tasks.
func (*TaskMonitor) Update ¶
func (tm *TaskMonitor) Update() bool
Update queries ECS for the latest tasks and returns true if there were any changes in the number of running tasks.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
findinstances
Sample application that lists all services and tasks running on a cluster.
|
Sample application that lists all services and tasks running on a cluster. |
listtasks
Sample application that lists all services and tasks running on a cluster.
|
Sample application that lists all services and tasks running on a cluster. |
monitor
Sample application that monitors the state of a service's tasks.
|
Sample application that monitors the state of a service's tasks. |
updatetask
Command which updates a task definition and waits for the service to become stable.
|
Command which updates a task definition and waits for the service to become stable. |