phases

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTask

func ExecuteTask(ctx context.Context, log *slog.Logger, t Task) (err error)

ExecuteTask logs start, then runs t.Do, then logs completion or failure in the "wide" format: task name, start time, status and elapsed duration. Any panic from t.Do is recovered, converted to an error, and logged as a failure.

Types

type Task

type Task interface {
	Name() string
	Do(ctx context.Context) error
}

Task is the interface implemented by all phase tasks.

func Parallel

func Parallel(log *slog.Logger, tasks ...Task) Task

Parallel returns a Task that executes the given tasks concurrently. All tasks are started at once. On the first error the context passed to remaining tasks is cancelled and the first error is returned. The provided logger is used to emit a wide log line for each task.

func Serial

func Serial(log *slog.Logger, tasks ...Task) Task

Serial returns a Task that executes the given tasks one by one in order, stopping and returning the first error encountered. The provided logger is used to emit a wide log line for each task.

Directories

Path Synopsis
oci

Jump to

Keyboard shortcuts

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