task

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallTask

func CallTask(t Task, args ...interface{}) ([]interface{}, error)

CallTask invokes the given Task (a function) with the provided arguments.

func GetFunctionName

func GetFunctionName(t Task) (string, error)

GetFunctionName returns the short name of the given Task (function).

func VerifySignature

func VerifySignature(t Task) error

Types

type Options

type Options struct {
	Retry *Retry `json:"retry,omitempty"`
}

Options contains configuration options for a task

type Retry

type Retry struct {
	MaxRetries   int           `json:"max_retries"`
	WaitDuration time.Duration `json:"wait_duration"`
	Factor       float32       `json:"factor"`
}

Retry contains retry configuration for a task

type Task

type Task interface{}

type TaskContext

type TaskContext interface {
	ExecuteTask(task Task, input ...interface{}) *TaskResult
}

type TaskInfo

type TaskInfo struct {
	Task    Task     `json:"-"`
	Options *Options `json:"options,omitempty"`
}

TaskInfo contains a task function and its options

type TaskResult

type TaskResult struct {
	Result []interface{}
	Error  error
}

func (*TaskResult) Get

func (t *TaskResult) Get(output ...interface{}) error

type Tasks

type Tasks struct {
	Tasks map[string]*TaskInfo
}

func NewTasks

func NewTasks() *Tasks

func (*Tasks) ExecuteTaskByName

func (t *Tasks) ExecuteTaskByName(name string, tctx TaskContext, input ...interface{}) ([]interface{}, error)

func (*Tasks) GetTaskByName

func (t *Tasks) GetTaskByName(name string) (Task, error)

func (*Tasks) GetTaskInfoByName

func (t *Tasks) GetTaskInfoByName(name string) (*TaskInfo, error)

func (*Tasks) GetTaskNames

func (t *Tasks) GetTaskNames() []string

func (*Tasks) RegisterTask

func (t *Tasks) RegisterTask(task Task) error

func (*Tasks) RegisterTaskWithOptions

func (t *Tasks) RegisterTaskWithOptions(task Task, options *Options) error

Jump to

Keyboard shortcuts

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