本文整理汇总了Golang中runtime-schema/models.Task.ExecutorID方法的典型用法代码示例。如果您正苦于以下问题:Golang Task.ExecutorID方法的具体用法?Golang Task.ExecutorID怎么用?Golang Task.ExecutorID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类runtime-schema/models.Task
的用法示例。
在下文中一共展示了Task.ExecutorID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ClaimTask
// The executor calls this when it wants to claim a runonce
// stagerBBS will retry this repeatedly if it gets a StoreTimeout error (up to N seconds?)
// If this fails, the executor should assume that someone else is handling the claim and should bail
func (self *executorBBS) ClaimTask(task *models.Task, executorID string) error {
originalValue := task.ToJSON()
task.UpdatedAt = self.timeProvider.Time().UnixNano()
task.State = models.TaskStateClaimed
task.ExecutorID = executorID
return retryIndefinitelyOnStoreTimeout(func() error {
return self.store.CompareAndSwap(storeadapter.StoreNode{
Key: taskSchemaPath(task),
Value: originalValue,
}, storeadapter.StoreNode{
Key: taskSchemaPath(task),
Value: task.ToJSON(),
})
})
}
示例2: demoteToPending
func demoteToPending(task models.Task) models.Task {
task.State = models.TaskStatePending
task.ExecutorID = ""
task.ContainerHandle = ""
return task
}