Documentation
¶
Overview ¶
Package workerpool provides bounded, lifecycle-aware execution for work submitted by message adapters and other optional capabilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed indicates that the processor is no longer accepting work. ErrClosed = errors.New("worker pool is closed") // ErrPanic indicates that a task panicked. The original panic value is // retained in the wrapped error. ErrPanic = errors.New("worker pool task panicked") )
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle represents accepted work. A handle must be awaited by callers that need to preserve message acknowledgement semantics.
type Options ¶
Options configures a Processor. Workers must be positive. QueueCapacity is the number of tasks allowed to wait behind active workers.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor executes accepted tasks with a fixed number of workers and a bounded waiting queue. Close drains accepted tasks before returning.
func (*Processor) Close ¶
Close stops accepting work, drains accepted tasks, and waits for workers to exit. If ctx expires first, Close returns its error while workers continue draining in the background; a later Close call can be used to wait again.
func (*Processor) Submit ¶
Submit waits for queue capacity, then accepts fn for execution. If ctx is cancelled while waiting for capacity, no work is accepted and ctx.Err() is returned. A successful submission returns a handle whose completion should be awaited before acknowledging a broker message.