task

package
v1.5.33 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	ID       uuid.UUID     `json:"id"`
	Task     *Task         `json:"task"`
	Run      string        `json:"run,omitempty"`
	Args     util.ValueMap `json:"args,omitempty"`
	Started  time.Time     `json:"started,omitempty"`
	Elapsed  int           `json:"elapsed,omitempty"`
	Status   string        `json:"status,omitempty"`
	Summary  string        `json:"summary,omitempty"`
	Logs     []string      `json:"logs,omitempty"`
	Data     any           `json:"data,omitempty"`
	Metadata util.ValueMap `json:"metadata,omitempty"`
	Success  bool          `json:"success"`
	Error    string        `json:"error,omitempty"`
	// 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) 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) 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) 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,omitempty"`
	Category      string          `json:"category,omitempty"`
	Icon          string          `json:"icon,omitempty"`
	Description   string          `json:"description,omitempty"`
	Tags          []string        `json:"tags,omitempty"`
	Fields        util.FieldDescs `json:"fields,omitempty"`
	Dangerous     string          `json:"dangerous,omitempty"`
	WebURL        string          `json:"webURL,omitempty"`
	MaxConcurrent int             `json:"maxConcurrent,omitempty"`
	// contains filtered or unexported fields
}

func NewTask

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

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 TaskFn) *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 TaskFn

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

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