worker

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

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

View Source
var ErrCanceled = errors.New("QUEUE_CANCELED: cancellation was requested")

ErrCanceled is the handler cancellation cause when durable cancellation is observed on a heartbeat.

View Source
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

func NewOperator

func NewOperator(store queueprovider.Store, provider golem.Provider, observer observe.Observer) (queue.Operator, error)

NewOperator exposes durable job control over a store. Every method acts on state the database owns; none of them reaches into a running handler.

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

func (worker *Worker) Run(ctx context.Context) error

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.

func (*Worker) Wake

func (worker *Worker) Wake()

Wake nudges an idle worker to claim without waiting for the poll interval. It never blocks and coalesces concurrent nudges into one.

Jump to

Keyboard shortcuts

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