Help us shape the future of Go! Take the 2026 Go Developer Survey

queue

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package queue persists scheduler runs and coordinates their execution and recovery.

Index

Constants

This section is empty.

Variables

View Source
var ErrRunConflict = errors.Sentinel("job run state changed")

ErrRunConflict indicates that execution ownership or state changed.

View Source
var ErrRunNotFound = errors.Sentinel("job run not found")

ErrRunNotFound indicates that neither a run nor its receipt exists.

Functions

This section is empty.

Types

type Queue

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

Queue persists work before dispatching it to the owning domain.

func New

func New(store *kv.KVService, execute, reconcile func(context.Context, st.Run) (st.Outcome, error)) *Queue

New uses the application's existing KV store; no in-memory admission exists.

func (*Queue) Cancel

func (q *Queue) Cancel(ctx context.Context, environmentID, jobID, runID string) (st.Run, error)

Cancel marks an unstarted queued run canceled. Runs already attempted locally or dispatched remotely must be reconciled rather than canceled as pending work.

func (*Queue) Checkpoint

func (q *Queue) Checkpoint(ctx context.Context, jobID, schedule string, next time.Time) error

Checkpoint records the next due occurrence atomically with overdue recovery.

func (*Queue) Get

func (q *Queue) Get(ctx context.Context, environmentID, jobID, runID string) (st.Run, error)

Get retrieves a run by environment, job, and run ID, including compacted idempotency receipts. It returns ErrRunNotFound when no matching record exists.

func (*Queue) List

func (q *Queue) List(ctx context.Context, environmentID, jobID string, page, limit int) (st.RunList, error)

List returns retained run history newest first, excluding compacted receipts. An empty job ID includes every job in the environment; pages are one-based.

func (*Queue) Records

func (q *Queue) Records(ctx context.Context) ([]st.QueueRecord, error)

Records reads all persisted queue records, including run history and receipts. Storage or decoding errors fail the read instead of returning an incomplete snapshot.

func (*Queue) Resolve

func (q *Queue) Resolve(ctx context.Context, environmentID, jobID, runID, resolvedBy string) (st.Run, error)

Resolve releases reviewed, inactive work without discarding its execution evidence.

func (*Queue) Retry

func (q *Queue) Retry(ctx context.Context, environmentID, jobID, runID string) (st.Run, error)

Retry requeues a failed, partial, or attention-required run without changing its ID or dropping target progress. Unconfirmed remote work cannot be retried here.

func (*Queue) SetObserver

func (q *Queue) SetObserver(observer st.RunObserver)

SetObserver connects activity projection before the queue starts accepting work.

func (*Queue) Start

func (q *Queue) Start(ctx context.Context) error

Start validates persisted state and starts dispatching on ctx. Repeated calls are harmless, but a stopped queue cannot be restarted; create a new instance.

func (*Queue) Stop

func (q *Queue) Stop(ctx context.Context) error

Stop rejects new submissions, cancels execution, and waits for workers until ctx expires. Unfinished claims remain persisted for startup reconciliation.

func (*Queue) Submit

func (q *Queue) Submit(ctx context.Context, request st.Request) (st.Run, error)

Submit persists acceptance before waking the dispatcher. Run IDs deduplicate requests within a job and environment. Manual and remote requests stay separate; other triggers coalesce pending work. Cancellation of ctx affects admission only, not an accepted run's lifetime.

func (*Queue) UpdateRun

func (q *Queue) UpdateRun(ctx context.Context, run st.Run, change func(*st.Run) error) error

UpdateRun atomically changes a persisted run or terminal receipt using compare and swap. The callback may run more than once and must not perform external side effects.

Jump to

Keyboard shortcuts

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