workerpool

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 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 Job

type Job[T any] struct {
	Handler StateHandler[T]
	Ctx     context.Context
	Data    T
}

type StateHandler

type StateHandler[T any] func(ctx context.Context, data T) error

type StatesPool

type StatesPool[T any] struct {
	// contains filtered or unexported fields
}

func NewWorkerPool

func NewWorkerPool[T any](numWorkers int) *StatesPool[T]

NewWorkerPool initializes new instance of worker pool.

func (*StatesPool[T]) InsertJob

func (pool *StatesPool[T]) InsertJob(job Job[T])

func (*StatesPool[T]) RunWorkers

func (pool *StatesPool[T]) RunWorkers()

RunWorkers runs workers which will be waiting for jobs to handle.

func (*StatesPool[T]) Shutdown

func (pool *StatesPool[T]) Shutdown()

Shutdown closes job channel and waits for all workers finished their works.

type WorkerPool

type WorkerPool[T any] interface {
	RunWorkers()
	Shutdown()
	InsertJob(job Job[T])
}

Jump to

Keyboard shortcuts

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