A task queue holds submitted tasks until a worker can process them. In an orchestration system, the manager places new tasks in a pending queue and handles them in first-in, first-out order; workers also contain task queues. section 2.3 section 4.1
The queue connects the main orchestration responsibilities:
- The manager accepts tasks, stores them as pending, selects suitable workers, and sends work onward. section 2.3
- The worker uses its queue alongside a runtime and task database to handle assigned work. section 4.1
A pending queue in a manager
A Go Manager skeleton declares Pending as a queue.Queue, alongside task and event maps, worker records, and task-to-worker mappings. Methods such as SelectWorker, UpdateTasks, and SendWork provide the next operations around queued tasks. section 2.3
Listing 2.8 The beginnings of our Manager skeleton
package manager
import(
"cube/task"
"fmt"
"github.com/golang-collections/collections/queue"
"github.com/google/uuid"
)
type Manager struct {
Pending queue.Queue
TaskDb map[string][]*task.Task
EventDb map[string][]*task.TaskEvent
Workers []string
WorkerTaskMap map[string][]uuid.UUID
TaskWorkerMap map[uuid.UUID]string
}
Inspect the Manager skeleton to see the queue positioned among task storage, worker tracking, and assignment maps. section 2.3
