task

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fn added in v1.6.17

type Fn func(ctx context.Context, res *Result, logger util.Logger) *Result

type Result

type Result struct {
	ID       uuid.UUID     `json:"id"`
	Task     *Task         `json:"task"`
	Run      string        `json:"run,omitzero"`
	Args     util.ValueMap `json:"args,omitzero"`
	Started  time.Time     `json:"started,omitzero"`
	Elapsed  int           `json:"elapsed,omitzero"`
	Status   string        `json:"status,omitzero"`
	Summary  string        `json:"summary,omitzero"`
	Logs     []string      `json:"logs,omitempty"`
	Data     any           `json:"data,omitzero"`
	Tags     []string      `json:"tags,omitempty"`
	Metadata util.ValueMap `json:"metadata,omitzero"`
	Success  bool          `json:"success"`
	Error    string        `json:"error,omitzero"`
	// contains filtered or unexported fields
}

func CompletedResult

func CompletedResult(task *Task, run string, args util.ValueMap, data any, err error, logs ...string) *Result

func NewResult

func NewResult(task *Task, run string, args util.ValueMap, fns ...ResultLogFn) *Result

func (*Result) AddLogs

func (r *Result) AddLogs(msgs ...string)

func (*Result) AddTags added in v1.6.15

func (r *Result) AddTags(tags ...string)

func (*Result) Complete

func (r *Result) Complete(data any, errs ...error) *Result

func (*Result) CompleteError

func (r *Result) CompleteError(err error) *Result

func (*Result) CompleteSimple

func (r *Result) CompleteSimple(data any) *Result

func (*Result) DataMap added in v1.5.21

func (r *Result) DataMap() util.ValueMap

func (*Result) EndTime

func (r *Result) EndTime() time.Time

func (*Result) HasTag added in v1.6.15

func (r *Result) HasTag(tag string) bool

func (*Result) IsOK

func (r *Result) IsOK() bool

func (*Result) Log

func (r *Result) Log(msg string, args ...any)

func (*Result) String

func (r *Result) String() string

func (*Result) Summarize

func (r *Result) Summarize() string

type ResultLogFn

type ResultLogFn func(key string, data any)

type Results

type Results []*Result

func (Results) AllTags added in v1.6.15

func (r Results) AllTags() []string

func (Results) ForRun added in v1.5.21

func (r Results) ForRun(run string) Results

func (Results) ForRunFirst added in v1.5.21

func (r Results) ForRunFirst(run string) *Result

func (Results) ForTask added in v1.5.21

func (r Results) ForTask(act string) Results

func (Results) ForTaskFirst added in v1.5.21

func (r Results) ForTaskFirst(act string) *Result

func (Results) Get

func (r Results) Get(id uuid.UUID) *Result

func (Results) Keys

func (r Results) Keys() []string

func (Results) Statuses

func (r Results) Statuses() ([]string, map[string]Results)

func (Results) String

func (r Results) String() string

type Service

type Service struct {
	RegisteredTasks Tasks `json:"tasks"`
	// contains filtered or unexported fields
}

func NewService

func NewService(fs filesystem.FileLoader, path string, initialTasks ...*Task) *Service

func (*Service) RegisterTask

func (s *Service) RegisterTask(t *Task) error

func (*Service) RemoveTask

func (s *Service) RemoveTask(key string) bool

func (*Service) Run

func (s *Service) Run(ctx context.Context, task *Task, run string, args util.ValueMap, logger util.Logger, fns ...exec.OutFn) *Result

func (*Service) RunAll

func (s *Service) RunAll(ctx context.Context, task *Task, run string, argsSet []util.ValueMap, logger util.Logger, fns ...exec.OutFn) (Results, error)

type Task

type Task struct {
	Key           string          `json:"key"`
	Title         string          `json:"title,omitzero"`
	Category      string          `json:"category,omitzero"`
	Icon          string          `json:"icon,omitzero"`
	Description   string          `json:"description,omitzero"`
	Tags          []string        `json:"tags,omitempty"`
	Fields        util.FieldDescs `json:"fields,omitempty"`
	Dangerous     string          `json:"dangerous,omitzero"`
	Expensive     bool            `json:"expensive,omitzero"`
	WebURL        string          `json:"webURL,omitzero"`
	MaxConcurrent int             `json:"maxConcurrent,omitzero"`
	// contains filtered or unexported fields
}

func NewTask

func NewTask(key string, title string, cat string, icon string, desc string, fns ...Fn) *Task

func (*Task) Breadcrumb added in v1.6.17

func (t *Task) Breadcrumb() string

func (*Task) Clone

func (t *Task) Clone() *Task

func (*Task) IconSafe

func (t *Task) IconSafe() string

func (*Task) ResultLogFn added in v1.5.21

func (t *Task) ResultLogFn(logger util.Logger, fns ...exec.OutFn) ResultLogFn

func (*Task) Run

func (t *Task) Run(ctx context.Context, run string, args util.ValueMap, logger util.Logger, fns ...exec.OutFn) *Result

func (*Task) RunWithResult

func (t *Task) RunWithResult(ctx context.Context, res *Result, logger util.Logger) *Result

func (*Task) TitleSafe

func (t *Task) TitleSafe() string

func (*Task) WebPath

func (t *Task) WebPath() string

func (*Task) WithFunction added in v1.5.21

func (t *Task) WithFunction(fn Fn) *Task

func (*Task) WithTags

func (t *Task) WithTags(tags []string) *Task

func (*Task) WithoutFunctions added in v1.5.21

func (t *Task) WithoutFunctions() *Task

type Tasks

type Tasks []*Task

func (Tasks) ByCategory

func (a Tasks) ByCategory(key string) Tasks

func (Tasks) Categories

func (a Tasks) Categories() []string

func (Tasks) Clone

func (a Tasks) Clone() Tasks

func (Tasks) Get

func (a Tasks) Get(key string) *Task

func (Tasks) Keys

func (a Tasks) Keys() []string

func (Tasks) Sort

func (a Tasks) Sort()

Jump to

Keyboard shortcuts

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