{"modulePath":"github.com/dockerstack/amazon-ecs-agent","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package dockerstate\n\n## Types\n\n```go\ntype DockerTaskEngineState struct {\n\t// contains filtered or unexported fields\n}\n```\ndockerTaskEngineState keeps track of all mappings between tasks we know about and containers docker runs It contains a mutex that can be used to ensure out-of-date state cannot be accessed before an update comes and to ensure multiple goroutines can safely work with it.\n\nThe methods on it will aquire the read lock, but not all aquire the write lock (sometimes it is up to the caller). This is because the write lock for containers should encapsulate the creation of the resource as well as adding, and creating the resource (docker container) is outside the scope of this package. This isn't ideal usage and I'm open to this being reworked/improved.\n\nSome information is duplicated in the interest of having efficient lookups\n\n```go\nfunc NewDockerTaskEngineState() *DockerTaskEngineState\n```\n\n```go\nfunc (state *DockerTaskEngineState) AddContainer(container *api.DockerContainer, task *api.Task)\n```\nAddContainer adds a container to the state. If the container has been added with only a name and no docker-id, this updates the state to include the docker id\n\n```go\nfunc (state *DockerTaskEngineState) AddTask(task *api.Task)\n```\nAddTask adds a new task to the state\n\n```go\nfunc (state *DockerTaskEngineState) AllTasks() []*api.Task\n```\n\n```go\nfunc (state *DockerTaskEngineState) ContainerById(id string) (*api.DockerContainer, bool)\n```\n\n```go\nfunc (state *DockerTaskEngineState) ContainerMapByArn(arn string) (map[string]*api.DockerContainer, bool)\n```\n\n```go\nfunc (state *DockerTaskEngineState) MarshalJSON() ([]byte, error)\n```\n\n```go\nfunc (state *DockerTaskEngineState) RemoveTask(task *api.Task)\n```\nRemoveTask removes a task from this state. It removes all containers and other associated metadata. It does aquire the write lock.\n\n```go\nfunc (state *DockerTaskEngineState) TaskByArn(arn string) (*api.Task, bool)\n```\n\n```go\nfunc (state *DockerTaskEngineState) TaskById(cid string) (*api.Task, bool)\n```\nTaskById retrieves the task of a given docker container id\n\n```go\nfunc (state *DockerTaskEngineState) UnmarshalJSON(data []byte) error\n```\n\n","path":"github.com/dockerstack/amazon-ecs-agent/agent/engine/dockerstate","name":"dockerstate","synopsis":"","isRedistributable":true}
