engine

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2015 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 22 Imported by: 0

Documentation

Overview

The 'engine' package contains code for interacting with container-running backends and handling events from them. It supports Docker as the sole task engine type.

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, error)

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

	InspectContainer(string) (*docker.Container, error)
	DescribeContainer(string) (api.ContainerStatus, 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, 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) RemoveContainer

func (dg *DockerGoClient) RemoveContainer(dockerId 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 a task engine

func NewDockerTaskEngine

func NewDockerTaskEngine(cfg *config.Config) *DockerTaskEngine

NewDockerTaskEngine returns a created, but uninitialized, DockerTaskEngine. The distinction between created and initialized is that when created it may be serialized/deserialized, but it will not communicate with docker until it is also initialized.

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) Init

func (engine *DockerTaskEngine) Init() error

Init initializes a DockerTaskEngine such that it may communicate with docker and operate normally. This function must be called before any other function, except serializing and deserializing, can succeed without error.

func (*DockerTaskEngine) ListTasks

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

func (*DockerTaskEngine) MarshalJSON

func (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)

MarshalJSON marshals into state directly

func (*DockerTaskEngine) MustInit

func (engine *DockerTaskEngine) MustInit()

MustInit blocks and retries until an engine can be initialized.

func (*DockerTaskEngine) PullContainer

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

func (*DockerTaskEngine) RemoveContainer

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

func (*DockerTaskEngine) SetSaver

func (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)

func (*DockerTaskEngine) StartContainer

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

func (*DockerTaskEngine) State

State is a function primarily meant for testing usage; it is explicitly not part of the TaskEngine interface and should not be relied upon. It returns an internal representation of the state of this DockerTaskEngine.

func (*DockerTaskEngine) StopContainer

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

func (*DockerTaskEngine) TaskEvents

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

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.

func (*DockerTaskEngine) UnmarshalJSON

func (engine *DockerTaskEngine) UnmarshalJSON(data []byte) error

UnmarshalJSON restores a previously marshaled task-engine state from json

type TaskEngine

type TaskEngine interface {
	Init() error
	MustInit()

	TaskEvents() <-chan api.ContainerStateChange
	SetSaver(statemanager.Saver)

	AddTask(*api.Task)

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

	UnmarshalJSON([]byte) error
	MarshalJSON() ([]byte, error)
}

func NewTaskEngine

func NewTaskEngine(cfg *config.Config) TaskEngine

NewTaskEngine returns a default TaskEngine

Directories

Path Synopsis
Package dockerauth handles storing auth configuration information for Docker registries.
Package dockerauth handles storing auth configuration information for Docker registries.
testutils
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package emptyvolume contains some information related to the 'emptyvolumes'
Package emptyvolume contains some information related to the 'emptyvolumes'
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.

Jump to

Keyboard shortcuts

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