async

package
Version: v0.8.27 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TaskReturnEmptyResult indicates an empty function return
	TaskReturnEmptyResult = iota
	// TaskReturnErrorOnly indicates an function that returns an error only
	TaskReturnErrorOnly
	// TaskReturnResultOnly indicates a function that return a interface{} result only
	TaskReturnResultOnly
	// TaskReturnResultAndError indicates a function that return both an interface{} and error result
	TaskReturnResultAndError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task structure contains task function reflection information, position in results, and the return type

func NewTask

func NewTask(index int, tf *TaskFunc) (*Task, error)

NewTask creates a new Task

type TaskFunc

type TaskFunc struct {
	Func interface{}
	Name string
}

TaskFunc is a function that returns nothing (empty), an error, or a result and error

type TaskResult

type TaskResult struct {
	Name   string
	Done   bool
	Error  error
	Result interface{}
	// contains filtered or unexported fields
}

TaskResult has the task Error or Result

func Parallel

func Parallel(ctx context.Context, tfs ...*TaskFunc) ([]TaskResult, error)

Parallel calls the set of tasks in parallel using the given context

func SequentialWithTimeout

func SequentialWithTimeout(ctx context.Context, timeout time.Duration, tfs ...*TaskFunc) ([]TaskResult, error)

SequentialWithTimeout calls the set of tasks in sequential order using the given context with timeout

type TaskResults

type TaskResults []TaskResult

TaskResults is as an array of TaskResult

func ParallelWithTimeout

func ParallelWithTimeout(ctx context.Context, timeout time.Duration, tfs ...*TaskFunc) (TaskResults, error)

ParallelWithTimeout calls the set of tasks in parallel using the given context with timeout

func Sequential

func Sequential(ctx context.Context, tfs ...*TaskFunc) (TaskResults, error)

Sequential calls the set of tasks in sequential order using the given context

func (TaskResults) Error

func (trs TaskResults) Error() string

Error return a string representation of the TaskResults Errors

func (TaskResults) HasError

func (trs TaskResults) HasError() bool

HasError determines if any of the TaskResults is an error

Jump to

Keyboard shortcuts

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