Documentation
¶
Overview ¶
Package worker runs registered job handlers against a durable job store. It claims within its free capacity, heartbeats the lease it was given, and records every outcome through the store's fenced transitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = errors.New("QUEUE_CANCELED: cancellation was requested")
ErrCanceled is the handler cancellation cause when durable cancellation is observed on a heartbeat.
var ErrLeaseLost = errors.New("QUEUE_LEASE_LOST: the job lease was lost")
ErrLeaseLost is the handler cancellation cause when a fenced renewal fails. The job now belongs to another worker and this handler's outcome is discarded.
Functions ¶
Types ¶
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker claims and executes registered job types. One Worker owns one Run at a time; a second concurrent Run is refused rather than sharing capacity.
func New ¶
func New(store queueprovider.Store, registry *queue.Registry, limits queue.Limits, provider golem.Provider, observer observe.Observer, resources ...queue.Resource) (*Worker, error)
New binds a registry to a durable store. Every refusal is CodeConfigInvalid and happens before any background work exists.
func (*Worker) Run ¶
Run owns the claim loop for the lifetime of ctx. It returns on cancellation or on an unrecoverable configuration failure; a store failure is retried rather than ending the worker. Handlers that ignore their context may still be running when Run returns: Go cannot kill a goroutine, so shutdown requests termination and then stops waiting.