Example #1
0
// ReadTask fetches a task from the database and applies a mask to the
// MaskedEnvironment field
func (db *TaskDB) ReadTask(id string) (eremetic.Task, error) {
	task, err := db.ReadUnmaskedTask(id)

	eremetic.ApplyMask(&task)

	return task, err
}
Example #2
0
// ListNonTerminalTasks returns a list of tasks that are not yet finished in one
// way or another.
func (db *TaskDB) ListNonTerminalTasks() ([]*eremetic.Task, error) {
	tasks := []*eremetic.Task{}

	err := db.conn.View(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte("tasks"))
		if b == nil {
			return bolt.ErrBucketNotFound
		}
		b.ForEach(func(_, v []byte) error {
			var task eremetic.Task
			json.Unmarshal(v, &task)
			if !task.IsTerminated() {
				eremetic.ApplyMask(&task)
				tasks = append(tasks, &task)
			}
			return nil
		})
		return nil
	})

	return tasks, err
}