Exemplo n.º 1
0
func (manager Manager) AcceptTask(teammate *model.Teammate, task *model.Task) bool {
	if !task.Assign(teammate.Uid()) {
		return false
	}
	if teammate.AcceptTask(task.Uid()) {
		manager.busManager.PublishEvent(event.AcceptTask, teammate.Identity,
			[]interface{}{teammate.Uid(), task.Uid()})
		return true
	}
	task.Requeue()
	return false
}
Exemplo n.º 2
0
func (manager Manager) QueueTask(queue *model.Queue, task *model.Task) bool {
	if !queue.AddTask(task.Uid()) {
		return false
	}
	if task.Enqueue(queue.Uid()) {
		return true
	}
	queue.DelTask(task.Uid())
	return false
}
Exemplo n.º 3
0
func (manager Manager) FinishTask(teammate *model.Teammate, task *model.Task) bool {
	if task.TeammateUid() != teammate.Uid() ||
		teammate.TaskUid() != task.Uid() {
		return false
	}
	if queue := manager.store.Queues.Find(task.QueueUid()); queue != nil {
		queue.DelTask(task.Uid())
	}
	if !task.Complete() {
		return false
	}
	teammate.FinishTask(task.Uid())
	manager.busManager.PublishEvent(event.CompleteTask, teammate.Identity,
		[]interface{}{teammate.Uid(), task.Uid()})
	return true
}