worker

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: GPL-2.0 Imports: 1 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	AddTask(t Task)
	AddTasks(t []Task)
	Start()
	StartWithWorkerCreator(f func() (Worker, error)) error
	Stop()
}

func NewPool

func NewPool(c *PoolConfig) Pool

NewPool is used to create a new pool instance

type PoolConfig

type PoolConfig struct {
	NumWorker int
	QueueSize int
}

PoolConfig Configuration for a worker pool.

type Task

type Task interface {
	WaitForResult() error
	Execute()
	ExecuteWithContext(ctx context.Context)
}

func NewTask

func NewTask(f func() error) Task

func NewTaskWithContext added in v0.8.0

func NewTaskWithContext(f func(ctx context.Context) error) Task

type Worker added in v0.8.0

type Worker interface {
	SetQueue(chan Task)
	Start()
	Stop()
}

Jump to

Keyboard shortcuts

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