worker_watcher

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

type Allocator func() (*worker.Process, error)

Allocator is responsible for worker allocation in the pool

type WorkerWatcher

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

func NewSyncWorkerWatcher

func NewSyncWorkerWatcher(allocator Allocator, log *slog.Logger, numWorkers uint64, allocateTimeout time.Duration) *WorkerWatcher

NewSyncWorkerWatcher is a constructor for the Watcher

func (*WorkerWatcher) AddWorker

func (ww *WorkerWatcher) AddWorker() error

func (*WorkerWatcher) Allocate

func (ww *WorkerWatcher) Allocate() error

func (*WorkerWatcher) Destroy

func (ww *WorkerWatcher) Destroy(ctx context.Context)

Destroy all underlying containers (but let them complete the task)

func (*WorkerWatcher) FreeWorkers

func (ww *WorkerWatcher) FreeWorkers() int

FreeWorkers returns the number of workers currently idling in the container.

func (*WorkerWatcher) List

func (ww *WorkerWatcher) List() []*worker.Process

List - this is O(n) operation, and it will return copy of the actual workers

func (*WorkerWatcher) NumWorkers

func (ww *WorkerWatcher) NumWorkers() uint64

NumWorkers returns the live number of workers tracked by the watcher.

func (*WorkerWatcher) Release

func (ww *WorkerWatcher) Release(w *worker.Process)

Release O(1) operation

func (*WorkerWatcher) RemoveWorker

func (ww *WorkerWatcher) RemoveWorker(ctx context.Context) error

func (*WorkerWatcher) Reset

func (ww *WorkerWatcher) Reset(ctx context.Context) uint64

func (*WorkerWatcher) Take

func (ww *WorkerWatcher) Take(ctx context.Context) (*worker.Process, error)

Take returns a worker in the Ready state from the container

func (*WorkerWatcher) Watch

func (ww *WorkerWatcher) Watch(workers []*worker.Process)

Directories

Path Synopsis
container

Jump to

Keyboard shortcuts

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