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 ¶
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.
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.
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.