task

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNil = errors.New("Task must be not nil")
	// ErrTaskMustBeFunc ...
	ErrTaskMustBeFunc = errors.New("Task must be a func type")
	// ErrTaskReturnsNoValue ...
	ErrTaskReturnsNoValue = errors.New("Task must return at least a single value")
	// ErrLastReturnValueMustBeError ..
	ErrLastReturnValueMustBeError = errors.New("Last return value of a task must be error")
)

Functions

func HumanReadableResults

func HumanReadableResults(results []reflect.Value) string

HumanReadableResults ...

func ReflectTaskResults

func ReflectTaskResults(taskResults []*TaskResult) ([]reflect.Value, error)

ReflectTaskResults ...

func Validate

func Validate(task *Task) error

Validate validates task function using reflection and makes sure it has a proper signature. Functions used as tasks must return at least a single value and the last return type must be error

Types

type Task

type Task struct {
	TaskId   string
	TaskFunc interface{}
	Args     []TaskArgument
	//	TaskStatus
	PreTaskHandler  func(*Task) error
	PostTaskHandler func(*Task) error
}

func (*Task) Run

func (t *Task) Run() ([]*TaskResult, error)

type TaskArgument

type TaskArgument struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

Types which can be used: bool, string, int int8 int16 int32 int64, uint uint8 uint16 uint32 uint64, float32 float64

type TaskResult

type TaskResult struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

TaskResult represents an actual return value of a processed task

Jump to

Keyboard shortcuts

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