worker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package worker runs the consumer side of dispatch: a loop that leases tasks from a queue, executes them on a node, and reports results. The control plane runs workers as goroutines for local scaling; `dispatch work` runs the same loop in its own process, which is what Kubernetes deployments and serverless containers replicate to scale out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

type Worker struct {
	// Deployment names the deployment, for metric labels.
	Deployment string
	// Queue supplies tasks; competing workers share it.
	Queue queue.Queue
	// Results receives each task's outcome.
	Results queue.Results
	// Node executes the tasks.
	Node node.Node
	// Recorder receives task metrics. Nil disables recording.
	Recorder metrics.Recorder
	// Backoff is the pause after a transient dequeue failure (e.g. the
	// control plane briefly unreachable). Zero means one second.
	Backoff time.Duration
}

Worker consumes tasks for one deployment on one node.

func (*Worker) Run

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

Run consumes tasks until ctx is done, which is the only error it returns. Task failures are reported as results, not returned: a bad task must never take the consumer down with it.

Jump to

Keyboard shortcuts

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