queue

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: 5 Imported by: 0

Documentation

Overview

Package queue is the producer/consumer seam of dispatch. Producers (the control plane API, or agents spawning sub-tasks) enqueue tasks; consumers (worker processes — goroutines locally, pods or serverless containers at scale) compete to dequeue and execute them. Scaling out is nothing more than adding consumers, which is why this interface is what Kubernetes-like substrates bind to.

The in-memory implementation here serves the single-binary beta. Remote consumers use the HTTP-backed implementation in package httpqueue; durable brokers (Redis, Pub/Sub, SQS) slot in behind the same two interfaces.

Index

Constants

This section is empty.

Variables

View Source
var ErrFull = errors.New("queue: full")

ErrFull is returned by Enqueue when the queue cannot accept more tasks.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is an in-process Queue for the single-binary deployment.

func NewMemory

func NewMemory(capacity int) *Memory

NewMemory returns a queue buffering up to capacity tasks (default 1024).

func (*Memory) Dequeue

func (m *Memory) Dequeue(ctx context.Context) (task.Task, error)

Dequeue implements Queue.

func (*Memory) Enqueue

func (m *Memory) Enqueue(_ context.Context, t task.Task) error

Enqueue implements Queue. It fails fast with ErrFull rather than blocking producers behind slow consumers.

type MemoryResults

type MemoryResults struct {
	// contains filtered or unexported fields
}

MemoryResults is an in-process Results store.

func NewMemoryResults

func NewMemoryResults() *MemoryResults

NewMemoryResults returns an empty results store.

func (*MemoryResults) Await

func (m *MemoryResults) Await(ctx context.Context, taskID string) (task.Result, error)

Await implements Results.

func (*MemoryResults) Get

func (m *MemoryResults) Get(_ context.Context, taskID string) (task.Result, bool, error)

Get implements Results.

func (*MemoryResults) Report

func (m *MemoryResults) Report(_ context.Context, r task.Result) error

Report implements Results.

type Queue

type Queue interface {
	// Enqueue adds t to the queue.
	Enqueue(ctx context.Context, t task.Task) error
	// Dequeue blocks until a task is available or ctx is done.
	Dequeue(ctx context.Context) (task.Task, error)
}

Queue carries tasks from producers to competing consumers. Delivery is at-most-once in the beta: a consumer that dies mid-task drops it.

type Results

type Results interface {
	// Report records the result of a completed task.
	Report(ctx context.Context, r task.Result) error
	// Await blocks until the result for taskID arrives or ctx is done.
	Await(ctx context.Context, taskID string) (task.Result, error)
	// Get returns the result for taskID if it has arrived.
	Get(ctx context.Context, taskID string) (task.Result, bool, error)
}

Results carries task outcomes back to whoever is waiting on them.

Directories

Path Synopsis
Package httpqueue implements queue.Queue and queue.Results over the dispatch control plane's HTTP API.
Package httpqueue implements queue.Queue and queue.Results over the dispatch control plane's HTTP API.

Jump to

Keyboard shortcuts

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