Add a /tasks endpoing and extra metdata to crawl tasks

This commit is contained in:
James Mills
2021-02-02 14:58:52 +10:00
parent 5cd5495622
commit 3923ff91ba
4 changed files with 52 additions and 1 deletions

View File

@@ -77,6 +77,15 @@ func (d *Dispatcher) Stop() {
d.quit <- true
}
// Tasks returns all tasks
func (d *Dispatcher) Tasks() map[string]TaskResult {
tasks := make(map[string]TaskResult)
for id, task := range d.taskMap {
tasks[id] = task.Result()
}
return tasks
}
// Lookup returns the matching `Task` given its id
func (d *Dispatcher) Lookup(id string) (Task, bool) {
task, ok := d.taskMap[id]