Documentation ¶
Index ¶
- type DockerTaskEngineState
- func (state *DockerTaskEngineState) AddContainer(container *api.DockerContainer, task *api.Task)
- func (state *DockerTaskEngineState) AddOrUpdateTask(task *api.Task) *api.Task
- func (state *DockerTaskEngineState) AllTasks() []*api.Task
- func (state *DockerTaskEngineState) ContainerById(id string) (*api.DockerContainer, bool)
- func (state *DockerTaskEngineState) ContainerMapByArn(arn string) (map[string]*api.DockerContainer, bool)
- func (state *DockerTaskEngineState) Lock()
- func (state *DockerTaskEngineState) MarshalJSON() ([]byte, error)
- func (state *DockerTaskEngineState) RemoveTask(task *api.Task)
- func (state *DockerTaskEngineState) TaskByArn(arn string) (*api.Task, bool)
- func (state *DockerTaskEngineState) TaskById(cid string) (*api.Task, bool)
- func (state *DockerTaskEngineState) Unlock()
- func (state *DockerTaskEngineState) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DockerTaskEngineState ¶
type DockerTaskEngineState struct {
// contains filtered or unexported fields
}
dockerTaskEngineState 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.
The 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.
Some information is duplicated in the interest of having efficient lookups
func NewDockerTaskEngineState ¶
func NewDockerTaskEngineState() *DockerTaskEngineState
func (*DockerTaskEngineState) AddContainer ¶
func (state *DockerTaskEngineState) AddContainer(container *api.DockerContainer, task *api.Task)
AddContainer adds a container to the state. It is expected that the caller aquires the write lock before calling this function. If the container has been added with only a name and no docker-id, this updates the state to include the docker id
func (*DockerTaskEngineState) AddOrUpdateTask ¶
func (state *DockerTaskEngineState) AddOrUpdateTask(task *api.Task) *api.Task
AddOrUpdate task adds a new task to the state, and if it already exists updates the existing task to match the argument's DesiredStatus. This method *does* aquire a write lock.
func (*DockerTaskEngineState) AllTasks ¶
func (state *DockerTaskEngineState) AllTasks() []*api.Task
func (*DockerTaskEngineState) ContainerById ¶
func (state *DockerTaskEngineState) ContainerById(id string) (*api.DockerContainer, bool)
func (*DockerTaskEngineState) ContainerMapByArn ¶
func (state *DockerTaskEngineState) ContainerMapByArn(arn string) (map[string]*api.DockerContainer, bool)
func (*DockerTaskEngineState) Lock ¶
func (state *DockerTaskEngineState) Lock()
Lock aquires the write lock for this state.
func (*DockerTaskEngineState) MarshalJSON ¶
func (state *DockerTaskEngineState) MarshalJSON() ([]byte, error)
func (*DockerTaskEngineState) RemoveTask ¶
func (state *DockerTaskEngineState) RemoveTask(task *api.Task)
RemoveTask removes a task from this state. It removes all containers and other associated metadata. It does aquire the write lock.
func (*DockerTaskEngineState) TaskByArn ¶
func (state *DockerTaskEngineState) TaskByArn(arn string) (*api.Task, bool)
func (*DockerTaskEngineState) TaskById ¶
func (state *DockerTaskEngineState) TaskById(cid string) (*api.Task, bool)
TaskById retrieves the task of a given docker container id
func (*DockerTaskEngineState) Unlock ¶
func (state *DockerTaskEngineState) Unlock()
Unlock releases the write lock for this state.
func (*DockerTaskEngineState) UnmarshalJSON ¶
func (state *DockerTaskEngineState) UnmarshalJSON(data []byte) error