tasks

package
v2.16.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[TaskArg any, TaskReturn any](ts *Tasks, name string, taskFunc TaskFunc[TaskArg, TaskReturn])

Types

type CleanupFunc

type CleanupFunc func(ctx context.Context) error

type Logger

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

func NewTasksLogger

func NewTasksLogger(ctx context.Context, mode LoggerMode) (*Logger, error)

func (*Logger) AddEntry

func (l *Logger) AddEntry(name string) *LoggerEntry

func (*Logger) CloseAndWait

func (l *Logger) CloseAndWait() error

func (*Logger) Write

func (l *Logger) Write(s *buildkit.SolveStatus)

type LoggerEntry

type LoggerEntry struct {
	Logs *os.File

	Start    func()
	Complete func(err error)
}

type LoggerMode

type LoggerMode string
const (
	PrinterModeQuiet LoggerMode = "quiet"
	PrinterModeAuto  LoggerMode = "auto"
	PrinterModeTty   LoggerMode = "tty"
)

type Task

type Task struct {
	Name string
	Ctx  context.Context
	Logs *os.File
	// contains filtered or unexported fields
}

func (*Task) AddToCleanUp

func (t *Task) AddToCleanUp(cleanupFunc CleanupFunc)

type TaskFunc

type TaskFunc[T any, U any] func(t *Task, args T) (nextArgs U, err error)

type Tasks

type Tasks struct {
	LoggerMode LoggerMode
	// contains filtered or unexported fields
}

func Begin

func Begin() *Tasks

func (*Tasks) Cleanup

func (ts *Tasks) Cleanup(ctx context.Context, logger *Logger, failed int)

Cleanup execute all tasks cleanup function before failed one in reverse order

func (*Tasks) Execute

func (ts *Tasks) Execute(ctx context.Context, data interface{}) (interface{}, error)

Execute tasks with interactive display and cleanup on fail

func (*Tasks) SetLoggerMode

func (ts *Tasks) SetLoggerMode(mode LoggerMode)

Jump to

Keyboard shortcuts

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