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

queue

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package queue provides a persistent work queue for incremental certification. Items are persisted to disk after each state change so progress survives crashes, rate limits, and multi-run processing.

Index

Constants

View Source
const DefaultMaxRetries = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	UnitID    string     `json:"unit_id"`
	FilePath  string     `json:"file_path"`
	Status    ItemStatus `json:"status"`
	Model     string     `json:"model,omitempty"`  // model that processed this item
	Error     string     `json:"error,omitempty"`  // last error message
	Reason    string     `json:"reason,omitempty"` // skip/complete reason
	Retries   int        `json:"retries"`          // number of failed attempts
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

Item is a single unit of work in the queue.

type ItemStatus

type ItemStatus string

ItemStatus represents the processing state of a queue item.

const (
	StatusPending    ItemStatus = "pending"
	StatusInProgress ItemStatus = "in_progress"
	StatusCompleted  ItemStatus = "completed"
	StatusSkipped    ItemStatus = "skipped"
	StatusFailed     ItemStatus = "failed"
)

type Queue

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

Queue is a persistent work queue for certification processing.

func Load

func Load(path string) (*Queue, error)

Load reads a queue from a JSON file.

func New

func New() *Queue

New creates an empty queue.

func (*Queue) BatchNext

func (q *Queue) BatchNext(n int) []Item

BatchNext returns up to n pending items, all marked in_progress.

func (*Queue) Complete

func (q *Queue) Complete(unitID, model string)

Complete marks an item as successfully processed.

func (*Queue) Enqueue

func (q *Queue) Enqueue(unitID, filePath string)

Enqueue adds a unit to the queue if not already present.

func (*Queue) Fail

func (q *Queue) Fail(unitID, errMsg string)

Fail marks an item as failed with an error message.

func (*Queue) Len

func (q *Queue) Len() int

Len returns the total number of items.

func (*Queue) Next

func (q *Queue) Next() (Item, bool)

Next returns the next pending or retryable item and marks it in_progress. Returns (item, true) if found, (zero, false) if queue is exhausted.

func (*Queue) Reset

func (q *Queue) Reset()

Reset sets all items back to pending (for re-processing).

func (*Queue) Save

func (q *Queue) Save(path string) error

Save writes the queue to a JSON file.

func (*Queue) Skip

func (q *Queue) Skip(unitID, reason string)

Skip marks an item as skipped (e.g., prescreen said no review needed).

func (*Queue) Stats

func (q *Queue) Stats() Stats

Stats returns current queue statistics.

type Stats

type Stats struct {
	Total      int `json:"total"`
	Pending    int `json:"pending"`
	InProgress int `json:"in_progress"`
	Completed  int `json:"completed"`
	Skipped    int `json:"skipped"`
	Failed     int `json:"failed"`
}

Stats holds queue statistics.

Jump to

Keyboard shortcuts

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