Documentation
¶
Overview ¶
Package worker provides registered, bounded workers with explicit retry, metrics, cancellation and draining.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Concurrency, Queue int
Report func(error)
Retry *retry.Policy
Observer instrument.Hook
}
Config controls a pool. Report is mandatory and must not panic. Retry repeats only explicitly idempotent, classified failures.
type Job ¶
Job executes one cancellable operation. It must honor ctx and must not retain caller-owned mutable inputs without synchronization.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool owns worker goroutines and bounded accepted work. Submit contexts control both admission and the individual job lifetime.
func NewWithConfig ¶
NewWithConfig validates all retry/admission settings before starting any owned goroutine.
func (*Pool) Cancel ¶
func (p *Pool) Cancel()
Cancel requests immediate cancellation. Shutdown can subsequently await actual worker termination.
func (*Pool) Register ¶
Register adds an immutable named job definition to this pool, never to a global registry.
func (*Pool) Shutdown ¶
Shutdown stops admission and drains accepted work; on deadline it cancels running work and returns immediately. Unstarted work canceled by the pool is discarded and reported with its context error. Handlers and Report must honor their documented contracts. Repeated calls wait on the same cleanup completion without creating extra wait goroutines.
func (*Pool) Stats ¶
Stats returns per-pool counters with no application labels or mandatory telemetry globals.