engine

package
v0.0.0-...-0dec3e3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2014 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 16 Imported by: 0

Documentation

Overview

The DockerTaskEngine is an abstraction over the DockerGoClient so that it does not have to know about tasks, only containers

Index

Constants

View Source
const (
	DEFAULT_TIMEOUT_SECONDS uint = 30

	DOCKER_ENDPOINT_ENV_VARIABLE = "DOCKER_HOST"
	DOCKER_DEFAULT_ENDPOINT      = "unix:///var/run/docker.sock"
)

Variables

This section is empty.

Functions

func TaskCompleted

func TaskCompleted(task *api.Task) bool

TaskCompleted evaluates if a task is at a steady state; that is that all the containers have reached their desired status as well as the task itself

Types

type ContainerNotFound

type ContainerNotFound struct {
	TaskArn       string
	ContainerName string
}

func (ContainerNotFound) Error

func (cnferror ContainerNotFound) Error() string

type DockerClient

type DockerClient interface {
	ContainerEvents() (<-chan DockerContainerChangeEvent, <-chan error)

	PullImage(image string) error
	CreateContainer(*docker.Config, string) (string, error)
	StartContainer(string, *docker.HostConfig) error
	StopContainer(string) error
	GetContainerName(string) (string, error)

	InspectContainer(string) (*docker.Container, error)
	// contains filtered or unexported methods
}

Interface to make testing it easier

type DockerContainerChangeEvent

type DockerContainerChangeEvent struct {
	DockerId string
	Image    string
	Status   api.ContainerStatus
}

type DockerGoClient

type DockerGoClient struct{}

Implements DockerClient

func NewDockerGoClient

func NewDockerGoClient() (*DockerGoClient, error)

func (*DockerGoClient) ContainerEvents

func (dg *DockerGoClient) ContainerEvents() (<-chan DockerContainerChangeEvent, <-chan error)

Listen to the docker event stream for container changes and pass them up

func (*DockerGoClient) CreateContainer

func (dg *DockerGoClient) CreateContainer(config *docker.Config, name string) (string, error)

func (*DockerGoClient) DescribeContainer

func (dg *DockerGoClient) DescribeContainer(dockerId string) (api.ContainerStatus, error)

func (*DockerGoClient) DescribeDockerImages

func (dg *DockerGoClient) DescribeDockerImages() (string, error)

DescribeDockerImages takes no arguments, and returns a JSON-encoded string of all of the images located on the host

func (*DockerGoClient) GetContainerName

func (dg *DockerGoClient) GetContainerName(id string) (string, error)

func (*DockerGoClient) InspectContainer

func (dg *DockerGoClient) InspectContainer(dockerId string) (*docker.Container, error)

func (*DockerGoClient) PullImage

func (dg *DockerGoClient) PullImage(image string) error

func (*DockerGoClient) StartContainer

func (dg *DockerGoClient) StartContainer(id string, hostConfig *docker.HostConfig) error

func (*DockerGoClient) StopContainer

func (dg *DockerGoClient) StopContainer(dockerId string) error

func (*DockerGoClient) StopContainerById

func (dg *DockerGoClient) StopContainerById(id string) error

type DockerImageResponse

type DockerImageResponse struct {
	Images []docker.APIImages
}

type DockerTaskEngine

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

The DockerTaskEngine interacts with docker to implement an task engine

func InitDockerTaskEngine

func InitDockerTaskEngine() (*DockerTaskEngine, error)

InitDockerTaskEngine returns the singleton instance of the DockerTaskEngine after, if necessary, initializing it

func (*DockerTaskEngine) AddTask

func (engine *DockerTaskEngine) AddTask(task *api.Task)

func (*DockerTaskEngine) ApplyContainerState

func (engine *DockerTaskEngine) ApplyContainerState(task *api.Task, container *api.Container)

func (*DockerTaskEngine) ApplyTaskState

func (engine *DockerTaskEngine) ApplyTaskState(task *api.Task)

ApplyTaskState checks if there is any work to be done on a given task or any of the containers belonging to it, and if there is work to be done that can be done, it does it. This function can be called frequently (and should be called anytime a container changes) and will do nothing if the task is at a steady state

func (*DockerTaskEngine) CreateContainer

func (engine *DockerTaskEngine) CreateContainer(task *api.Task, container *api.Container) error

func (*DockerTaskEngine) KillContainer

func (engine *DockerTaskEngine) KillContainer(task *api.Task, container *api.Container) error

func (*DockerTaskEngine) ListTasks

func (engine *DockerTaskEngine) ListTasks() ([]*api.Task, error)

func (*DockerTaskEngine) PullContainer

func (engine *DockerTaskEngine) PullContainer(task *api.Task, container *api.Container) error

func (*DockerTaskEngine) StartContainer

func (engine *DockerTaskEngine) StartContainer(task *api.Task, container *api.Container) error

func (*DockerTaskEngine) StopContainer

func (engine *DockerTaskEngine) StopContainer(task *api.Task, container *api.Container) error

func (*DockerTaskEngine) TaskEvents

func (engine *DockerTaskEngine) TaskEvents() (<-chan api.ContainerStateChange, <-chan error)

TaskEvents returns channels to read task and container state changes. These changes should be read as soon as possible as them not being read will block processing tasks and events.

type TaskEngine

type TaskEngine interface {
	TaskEvents() (<-chan api.ContainerStateChange, <-chan error)

	AddTask(*api.Task)

	ListTasks() ([]*api.Task, error)
}

func MustTaskEngine

func MustTaskEngine() TaskEngine

MustTaskEngine tries to create a task engine until it succeeds without error. It will print a error message for the first error.

func NewTaskEngine

func NewTaskEngine() (TaskEngine, error)

NewTaskEngine returns a default TaskEngine

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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