{"modulePath":"github.com/dockerstack/amazon-ecs-agent","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package engine\n\nThe 'engine' package contains code for interacting with container-running backends and handling events from them. It supports Docker as the sole task engine type.\n\nThe DockerTaskEngine is an abstraction over the DockerGoClient so that it does not have to know about tasks, only containers\n\n## Constants\n\n```go\nconst (\n\tDOCKER_ENDPOINT_ENV_VARIABLE = \"DOCKER_HOST\"\n\tDOCKER_DEFAULT_ENDPOINT      = \"unix:///var/run/docker.sock\"\n)\n```\n\n## Types\n\n```go\ntype CannotXContainerError struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (err CannotXContainerError) Error() string\n```\n\n```go\nfunc (err CannotXContainerError) ErrorName() string\n```\n\n```go\ntype ContainerNotFound struct {\n\tTaskArn       string\n\tContainerName string\n}\n```\n\n```go\nfunc (cnferror ContainerNotFound) Error() string\n```\n\n```go\ntype ContainerVanishedError struct{}\n```\n\n```go\nfunc (err ContainerVanishedError) Error() string\n```\n\n```go\nfunc (err ContainerVanishedError) ErrorName() string\n```\n\n```go\ntype DockerClient interface {\n\tContainerEvents(ctx context.Context) (\u003c-chan DockerContainerChangeEvent, error)\n\n\tPullImage(image string) DockerContainerMetadata\n\tCreateContainer(*docker.Config, *docker.HostConfig, string) DockerContainerMetadata\n\tStartContainer(string) DockerContainerMetadata\n\tStopContainer(string) DockerContainerMetadata\n\tDescribeContainer(string) (api.ContainerStatus, DockerContainerMetadata)\n\n\tRemoveContainer(string) error\n\n\tGetContainerName(string) (string, error)\n\tInspectContainer(string) (*docker.Container, error)\n\n\tListContainers(bool) ListContainersResponse\n\n\tVersion() (string, error)\n}\n```\nInterface to make testing it easier\n\n```go\ntype DockerContainerChangeEvent struct {\n\tStatus api.ContainerStatus\n\n\tDockerContainerMetadata\n}\n```\n\n```go\ntype DockerContainerMetadata struct {\n\tDockerId     string\n\tExitCode     *int\n\tPortBindings []api.PortBinding\n\tError        error\n\tVolumes      map[string]string\n}\n```\n\n```go\ntype DockerGoClient struct {\n\t// contains filtered or unexported fields\n}\n```\nImplements DockerClient\n\n```go\nfunc NewDockerGoClient() (*DockerGoClient, error)\n```\n\n```go\nfunc (dg *DockerGoClient) ContainerEvents(ctx context.Context) (\u003c-chan DockerContainerChangeEvent, error)\n```\nListen to the docker event stream for container changes and pass them up\n\n```go\nfunc (dg *DockerGoClient) CreateContainer(config *docker.Config, hostConfig *docker.HostConfig, name string) DockerContainerMetadata\n```\n\n```go\nfunc (dg *DockerGoClient) DescribeContainer(dockerId string) (api.ContainerStatus, DockerContainerMetadata)\n```\n\n```go\nfunc (dg *DockerGoClient) GetContainerName(id string) (string, error)\n```\n\n```go\nfunc (dg *DockerGoClient) InspectContainer(dockerId string) (*docker.Container, error)\n```\n\n```go\nfunc (dg *DockerGoClient) ListContainers(all bool) ListContainersResponse\n```\nListContainers returns a slice of container IDs.\n\n```go\nfunc (dg *DockerGoClient) PullImage(image string) DockerContainerMetadata\n```\n\n```go\nfunc (dg *DockerGoClient) RemoveContainer(dockerId string) error\n```\n\n```go\nfunc (dg *DockerGoClient) SetGoDockerClient(to dockerclient.Client)\n```\n\n```go\nfunc (dg *DockerGoClient) StartContainer(id string) DockerContainerMetadata\n```\n\n```go\nfunc (dg *DockerGoClient) StopContainer(dockerId string) DockerContainerMetadata\n```\n\n```go\nfunc (dg *DockerGoClient) Version() (string, error)\n```\n\n```go\ntype DockerImageResponse struct {\n\tImages []docker.APIImages\n}\n```\n\n```go\ntype DockerStateError struct {\n\t// contains filtered or unexported fields\n}\n```\nDockerStateError is a wrapper around the error docker puts in the '.State.Error' field of its inspect output.\n\n```go\nfunc NewDockerStateError(err string) DockerStateError\n```\n\n```go\nfunc (err DockerStateError) Error() string\n```\n\n```go\nfunc (err DockerStateError) ErrorName() string\n```\n\n```go\ntype DockerTaskEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nThe DockerTaskEngine interacts with docker to implement a task engine\n\n```go\nfunc NewDockerTaskEngine(cfg *config.Config) *DockerTaskEngine\n```\nNewDockerTaskEngine 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.\n\n```go\nfunc (engine *DockerTaskEngine) AddTask(task *api.Task) error\n```\n\n```go\nfunc (engine *DockerTaskEngine) CheckTaskState(task *api.Task)\n```\nCheckTaskState inspects the state of all containers within a task and writes their state to the managed task's container channel.\n\n```go\nfunc (engine *DockerTaskEngine) Disable()\n```\nDisable prevents this engine from managing any additional tasks.\n\n```go\nfunc (engine *DockerTaskEngine) Init() error\n```\nInit 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.\n\n```go\nfunc (engine *DockerTaskEngine) ListTasks() ([]*api.Task, error)\n```\n\n```go\nfunc (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)\n```\nMarshalJSON marshals into state directly\n\n```go\nfunc (engine *DockerTaskEngine) MustInit()\n```\nMustInit blocks and retries until an engine can be initialized.\n\n```go\nfunc (engine *DockerTaskEngine) SetDockerClient(client DockerClient)\n```\nSetDockerClient provides a way to override the client used for communication with docker as a testing hook.\n\n```go\nfunc (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)\n```\n\n```go\nfunc (engine *DockerTaskEngine) Shutdown()\n```\nShutdown makes a best-effort attempt to cleanup after the task engine. This should not be relied on for anything more complicated than testing.\n\n```go\nfunc (engine *DockerTaskEngine) State() *dockerstate.DockerTaskEngineState\n```\nState 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.\n\n```go\nfunc (engine *DockerTaskEngine) TaskEvents() (\u003c-chan api.TaskStateChange, \u003c-chan api.ContainerStateChange)\n```\nTaskEvents 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 the task referenced by the event.\n\n```go\nfunc (engine *DockerTaskEngine) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON restores a previously marshaled task-engine state from json\n\n```go\nfunc (engine *DockerTaskEngine) Version() (string, error)\n```\nVersion returns the underlying docker version.\n\n```go\ntype DockerTimeoutError struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (err *DockerTimeoutError) Error() string\n```\n\n```go\nfunc (err *DockerTimeoutError) ErrorName() string\n```\n\n```go\ntype ListContainersResponse struct {\n\tDockerIds []string\n\tError     error\n}\n```\nListContainersResponse encapsulates the response from the docker client for the ListContainers call.\n\n```go\ntype OutOfMemoryError struct{}\n```\n\n```go\nfunc (err OutOfMemoryError) Error() string\n```\n\n```go\nfunc (err OutOfMemoryError) ErrorName() string\n```\n\n```go\ntype TaskEngine interface {\n\tInit() error\n\tMustInit()\n\t// Disable *must* only be called when this engine will no longer be used\n\t// (e.g. right before exiting down the process). It will irreversably stop\n\t// this task engine from processing new tasks\n\tDisable()\n\n\tTaskEvents() (\u003c-chan api.TaskStateChange, \u003c-chan api.ContainerStateChange)\n\tSetSaver(statemanager.Saver)\n\n\t// AddTask adds a new task to the task engine and manages its container's\n\t// lifecycle. If it returns an error, the task was not added.\n\tAddTask(*api.Task) error\n\n\tListTasks() ([]*api.Task, error)\n\n\tVersion() (string, error)\n\n\tjson.Marshaler\n\tjson.Unmarshaler\n}\n```\n\n```go\nfunc NewTaskEngine(cfg *config.Config) TaskEngine\n```\nNewTaskEngine returns a default TaskEngine\n\n","path":"github.com/dockerstack/amazon-ecs-agent/agent/engine","name":"engine","synopsis":"The 'engine' package contains code for interacting with container-running backends and handling events from them.","isRedistributable":true}
