A task store saves and retrieves task records through a Store interface. Wrapping the underlying map keeps the manager independent from map mechanics while allowing both manager and worker to persist tasks. section 11.3
Saving a started task
When the manager receives POST /tasks, it calls Put to save the task locally, then sends the task to the worker, which calls Put in its own store.
Listing 11.3 The InMemoryTaskStore struct
type InMemoryTaskStore struct {
Db map[string]*task.Task
}
func NewInMemoryTaskStore() *InMemoryTaskStore {
return &InMemoryTaskStore{
Db: make(map[string]*task.Task),
}
}
Inspect the minimal in-memory store structure and constructor. section 11.3
