本文整理汇总了Golang中github.com/aws/amazon-ecs-agent/agent/api.Container.DesiredTerminal方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.DesiredTerminal方法的具体用法?Golang Container.DesiredTerminal怎么用?Golang Container.DesiredTerminal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/amazon-ecs-agent/agent/api.Container
的用法示例。
在下文中一共展示了Container.DesiredTerminal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: containerNextState
// containerNextState determines the next state a container should go to.
// It returns: The state it should transition to, a bool indicating whether any
// action is required, and a bool indicating whether a known status change is
// possible.
// 'Stopped, false, true' -> "You can move it to known stopped, but you don't have to call a transition function"
// 'Running, true, true' -> "You can move it to running and you need to call the transition function"
// 'None, false, false' -> "This should not be moved; it has unresolved dependencies or is complete; no knownstatus change"
func (mtask *managedTask) containerNextState(container *api.Container) (api.ContainerStatus, bool, bool) {
clog := log.New("task", mtask.Task, "container", container)
if container.KnownStatus == container.DesiredStatus {
clog.Debug("Container at desired status", "desired", container.DesiredStatus)
return api.ContainerStatusNone, false, false
}
if container.KnownStatus > container.DesiredStatus {
clog.Debug("Container past desired status")
return api.ContainerStatusNone, false, false
}
if !dependencygraph.DependenciesAreResolved(container, mtask.Containers) {
clog.Debug("Can't apply state to container yet; dependencies unresolved", "state", container.DesiredStatus)
return api.ContainerStatusNone, false, false
}
var nextState api.ContainerStatus
if container.DesiredTerminal() {
nextState = api.ContainerStopped
if container.KnownStatus != api.ContainerRunning {
// If it's not currently running we do not need to do anything to make it become stopped.
return nextState, false, true
}
} else {
nextState = container.KnownStatus + 1
}
return nextState, true, true
}