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
- func TaskCompleted(task *api.Task) bool
- type ContainerNotFound
- type DockerClient
- type DockerContainerChangeEvent
- type DockerGoClient
- func (dg *DockerGoClient) ContainerEvents() (<-chan DockerContainerChangeEvent, error)
- func (dg *DockerGoClient) CreateContainer(config *docker.Config, name string) (string, error)
- func (dg *DockerGoClient) DescribeContainer(dockerId string) (api.ContainerStatus, error)
- func (dg *DockerGoClient) DescribeDockerImages() (string, error)
- func (dg *DockerGoClient) GetContainerName(id string) (string, error)
- func (dg *DockerGoClient) InspectContainer(dockerId string) (*docker.Container, error)
- func (dg *DockerGoClient) PullImage(image string) error
- func (dg *DockerGoClient) RemoveContainer(dockerId string) error
- func (dg *DockerGoClient) StartContainer(id string, hostConfig *docker.HostConfig) error
- func (dg *DockerGoClient) StopContainer(dockerId string) error
- func (dg *DockerGoClient) StopContainerById(id string) error
- type DockerImageResponse
- type DockerTaskEngine
- func (engine *DockerTaskEngine) AddTask(task *api.Task)
- func (engine *DockerTaskEngine) ApplyContainerState(task *api.Task, container *api.Container)
- func (engine *DockerTaskEngine) ApplyTaskState(task *api.Task)
- func (engine *DockerTaskEngine) CreateContainer(task *api.Task, container *api.Container) error
- func (engine *DockerTaskEngine) Init() error
- func (engine *DockerTaskEngine) ListTasks() ([]*api.Task, error)
- func (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)
- func (engine *DockerTaskEngine) MustInit()
- func (engine *DockerTaskEngine) PullContainer(task *api.Task, container *api.Container) error
- func (engine *DockerTaskEngine) RemoveContainer(task *api.Task, container *api.Container) error
- func (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)
- func (engine *DockerTaskEngine) StartContainer(task *api.Task, container *api.Container) error
- func (engine *DockerTaskEngine) State() *dockerstate.DockerTaskEngineState
- func (engine *DockerTaskEngine) StopContainer(task *api.Task, container *api.Container) error
- func (engine *DockerTaskEngine) TaskEvents() <-chan api.ContainerStateChange
- func (engine *DockerTaskEngine) UnmarshalJSON(data []byte) error
- type TaskEngine
Constants ¶
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 ¶
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 ¶
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 (*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 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 (*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 (*DockerTaskEngine) RemoveContainer ¶
func (*DockerTaskEngine) SetSaver ¶
func (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)
func (*DockerTaskEngine) StartContainer ¶
func (*DockerTaskEngine) State ¶
func (engine *DockerTaskEngine) State() *dockerstate.DockerTaskEngineState
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 (*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
Source Files ¶
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. |