Documentation ¶
Overview ¶
Package uitask provided management of in-process long-running tasks that are exposed to the UI.
Index ¶
- type Controller
- type CounterValue
- func BytesCounter(v int64) CounterValue
- func ErrorBytesCounter(v int64) CounterValue
- func ErrorCounter(v int64) CounterValue
- func NoticeBytesCounter(v int64) CounterValue
- func NoticeCounter(v int64) CounterValue
- func SimpleCounter(v int64) CounterValue
- func WarningBytesCounter(v int64) CounterValue
- func WarningCounter(v int64) CounterValue
- type Info
- type LogEntry
- type LogLevel
- type Manager
- func (m *Manager) CancelTask(taskID string)
- func (m *Manager) GetTask(taskID string) (Info, bool)
- func (m *Manager) ListTasks() []Info
- func (m *Manager) Run(ctx context.Context, kind, description string, task TaskFunc) error
- func (m *Manager) TaskLog(taskID string) []LogEntry
- func (m *Manager) TaskSummary() map[Status]int
- type Status
- type TaskFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { CurrentTaskID() string OnCancel(cancelFunc context.CancelFunc) ReportCounters(counters map[string]CounterValue) ReportProgressInfo(text string) }
Controller allows the task to communicate with task manager and receive signals.
type CounterValue ¶
type CounterValue struct { Value int64 `json:"value"` Units string `json:"units,omitempty"` Level string `json:"level"` // "", "notice", "warning" or "error" }
CounterValue describes the counter value reported by task with optional units for presentation.
func BytesCounter ¶
func BytesCounter(v int64) CounterValue
BytesCounter returns CounterValue for the number of bytes.
func ErrorBytesCounter ¶
func ErrorBytesCounter(v int64) CounterValue
ErrorBytesCounter returns CounterValue for the number of bytes.
func ErrorCounter ¶
func ErrorCounter(v int64) CounterValue
ErrorCounter returns simple numeric CounterValue without units.
func NoticeBytesCounter ¶
func NoticeBytesCounter(v int64) CounterValue
NoticeBytesCounter returns CounterValue for the number of bytes.
func NoticeCounter ¶
func NoticeCounter(v int64) CounterValue
NoticeCounter returns simple numeric CounterValue without units.
func SimpleCounter ¶
func SimpleCounter(v int64) CounterValue
SimpleCounter returns simple numeric CounterValue without units.
func WarningBytesCounter ¶
func WarningBytesCounter(v int64) CounterValue
WarningBytesCounter returns CounterValue for the number of bytes.
func WarningCounter ¶
func WarningCounter(v int64) CounterValue
WarningCounter returns simple numeric CounterValue without units.
type Info ¶
type Info struct { TaskID string `json:"id"` StartTime time.Time `json:"startTime"` EndTime *time.Time `json:"endTime,omitempty"` Kind string `json:"kind"` // Maintenance, Snapshot, Restore, etc. Description string `json:"description"` Status Status `json:"status"` ProgressInfo string `json:"progressInfo"` ErrorMessage string `json:"errorMessage,omitempty"` Counters map[string]CounterValue `json:"counters"` LogLines []LogEntry `json:"-"` // contains filtered or unexported fields }
Info represents information about a task (running or finished).
type LogEntry ¶
type LogEntry struct { Timestamp float64 `json:"ts"` // unix timestamp possibly with fractional seconds. Module string `json:"mod"` Level LogLevel `json:"level"` Text string `json:"msg"` }
LogEntry contains one output from a single log statement.
type Manager ¶
type Manager struct { MaxFinishedTasks int MaxLogMessagesPerTask int // contains filtered or unexported fields }
Manager manages UI tasks.
func (*Manager) CancelTask ¶
CancelTask retrieves the log from the task.
func (*Manager) ListTasks ¶
ListTasks lists all running and some recently-finished tasks up to configured limits.
func (*Manager) Run ¶
Run executes the provided task in the current goroutine while allowing it to be externally examined and canceled.
func (*Manager) TaskSummary ¶
TaskSummary returns the summary (number of tasks by status).