task

package
v0.0.0-...-1fa5987 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithTask

func ContextWithTask(ctx context.Context, task *Task) context.Context

Types

type Task

type Task struct {
	context.Context
	// contains filtered or unexported fields
}

func CurrentTask

func CurrentTask(ctx context.Context) *Task

func (*Task) CreateChild

func (t *Task) CreateChild(name string) *Task

func (*Task) Fail

func (t *Task) Fail(err error)

Marks this Task as failed, which will be reported by Finish().

func (*Task) Finish

func (t *Task) Finish() error

Waits for any subtasks to complete, then reports this task as complete. Status will be failed if any subtask fails, or if Fail() is called. It is safe to call Finish() multiple times.

func (*Task) Go

func (t *Task) Go(name string, f func(task *Task) error)

func (*Task) ID

func (t *Task) ID() string

ID of this task. Might be empty string if task tracking failed.

func (*Task) JobID

func (t *Task) JobID() string

Job ID associated with this task. Might be empty string if task tracking failed.

func (*Task) ReportMessage

func (t *Task) ReportMessage(message string)

func (*Task) ReportProgress

func (t *Task) ReportProgress(current, total int)

func (*Task) RunChild

func (t *Task) RunChild(name string, f func(task *Task) error) error

func (*Task) Start

func (t *Task) Start()

Marks a task as started. The caller is responsible for also calling .Finish().

func (*Task) StartChild

func (t *Task) StartChild(name string) *Task

func (*Task) Wait

func (t *Task) Wait() error

type TaskTracker

type TaskTracker struct {
	Store  api.TaskStore
	Logger logging.Logger
}

func (*TaskTracker) CreateTask

func (tt *TaskTracker) CreateTask(ctx context.Context, name string) *Task

Creates a task in the Pending state. Call task.Start() on it, or use StartTask method for convenience.

func (*TaskTracker) StartTask

func (tt *TaskTracker) StartTask(ctx context.Context, name string) *Task

Creates and starts a task. See `Task.Start()` for usage instructions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL