task

package
v1.8.2-0...-f7776fc Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: GPL-2.0, GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package task provides primitives to track tasks via contexts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrContext

func ErrContext(errp *error, ctx context.Context)

ErrContext adds current task name to error on error return.

To work as intended it should be called under defer like this:

     func myfunc(ctx, ...) (..., err error) {
		ctx = task.Running("doing something")
		defer task.ErrContext(&err, ctx)
		...

Please see lab.nexedi.com/kirr/go123/xerr.Context for semantic details.

func Running

func Running(ctx context.Context, name string) context.Context

Running creates new task and returns new context with that task set to current.

func Runningf

func Runningf(ctx context.Context, format string, argv ...interface{}) context.Context

Runningf is Running cousin with formatting support.

Types

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task represents currently running operation.

func Current

func Current(ctx context.Context) *Task

Current returns current task represented by context.

if there is no current task - it returns nil.

func (*Task) Name

func (t *Task) Name() string

func (*Task) Parent

func (t *Task) Parent() *Task

func (*Task) String

func (t *Task) String() string

String returns string representing whole operational stack.

For example if task "c" is running under task "b" which in turn is running under task "a" - the operational stack will be "a: b: c".

nil Task is represented as "".

Jump to

Keyboard shortcuts

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