engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 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)

	Version() (string, error)
}

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

func (*DockerGoClient) Version added in v1.0.0

func (dg *DockerGoClient) Version() (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) error

func (*DockerTaskEngine) Disable added in v1.0.0

func (engine *DockerTaskEngine) Disable()

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

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

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

func (*DockerTaskEngine) Version added in v1.0.0

func (engine *DockerTaskEngine) Version() (string, error)

Version returns the underlying docker version.

type TaskEngine

type TaskEngine interface {
	Init() error
	MustInit()
	// Disable *must* only be called when this engine will no longer be used
	// (e.g. right before exiting down the process). It will irreversably stop
	// this task engine from processing new tasks
	Disable()

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

	// AddTask adds a new task to the task engine and manages its container's
	// lifecycle. If it returns an error, the task was not added.
	AddTask(*api.Task) error

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

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

	Version() (string, 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