sync

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkPool

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

WorkPool is a pool of work to be done.

func NewWorkPool

func NewWorkPool(ctx context.Context, workers int, opts ...WorkPoolOption) *WorkPool

NewWorkPool creates a new work pool. The workers argument specifies the number of concurrent workers to run the work. The queue will chunk the work into batches of workers size.

func (*WorkPool) Add

func (wq *WorkPool) Add(id string, fn func())

Add adds a new job to the pool. If the job already exists, it is a no-op.

func (*WorkPool) Run

func (wq *WorkPool) Run()

Run starts the workers and waits for them to finish.

func (*WorkPool) Status

func (wq *WorkPool) Status(id string) bool

Status checks if a job is in the queue.

type WorkPoolOption

type WorkPoolOption func(*WorkPool)

WorkPoolOption is a function that configures a WorkPool.

func WithWorkPoolLogger

func WithWorkPoolLogger(logger func(string, ...interface{})) WorkPoolOption

WithWorkPoolLogger sets the logger to use.

Jump to

Keyboard shortcuts

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