taskgroup

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskGroupStopped    = errors.New("task group is stopped")
	ErrTaskGroupMaxWorkers = errors.New("max workers must be greater than 0")
)

Functions

This section is empty.

Types

type Stats

type Stats struct {
	Total         int
	Created       int
	Pending       int
	Started       int
	Done          int
	Failed        int
	Canceled      int
	MaxWorkers    int
	ActiveWorkers int
	Stopped       bool
}

type TaskGroup

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

func New

func New(maxWorkers int) (*TaskGroup, error)

func (*TaskGroup) ActiveWorkers

func (tg *TaskGroup) ActiveWorkers() int

ActiveWorkers returns the current number of active workers.

func (*TaskGroup) AvailableWorkers

func (tg *TaskGroup) AvailableWorkers() int

AvailableWorkers returns the number of available worker slots.

func (*TaskGroup) IsStopped

func (tg *TaskGroup) IsStopped() bool

IsStopped returns true if the pool has been stopped.

func (*TaskGroup) MaxWorkers

func (tg *TaskGroup) MaxWorkers() int

MaxWorkers returns the maximum number of concurrent workers.

func (*TaskGroup) Stats

func (tg *TaskGroup) Stats() Stats

Stats returns statistics about the pool's tasks.

func (*TaskGroup) Stop

func (tg *TaskGroup) Stop()

func (*TaskGroup) Submit

func (tg *TaskGroup) Submit(ctx context.Context, def task.Definition) (*task.Task, error)

func (*TaskGroup) SubmitBatch

func (tg *TaskGroup) SubmitBatch(ctx context.Context, defs []task.Definition) ([]*task.Task, error)

func (*TaskGroup) SubmitWithErrGroup

func (tg *TaskGroup) SubmitWithErrGroup(ctx context.Context, defs []task.Definition) error

func (*TaskGroup) Tasks

func (tg *TaskGroup) Tasks() []*task.Task

func (*TaskGroup) Wait

func (tg *TaskGroup) Wait()

Jump to

Keyboard shortcuts

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