queue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package queue holds the work queues: one file per session and one for the inbox, a line per item. Its functions return typed errors, so the command line and the dashboard can say the same thing in their own way.

Index

Constants

View Source
const MaxItem = 200

MaxItem is the longest item, in characters.

Variables

View Source
var ErrBlank = errors.New("nothing to queue")

ErrBlank says the text to queue holds nothing.

View Source
var ErrEmpty = errors.New("queue empty")

ErrEmpty says the queue has no items.

Functions

func Label

func Label(id state.ID) string

Label is the short name of a queue: "inbox", or the first four characters of a session id.

func LabelFor added in v0.6.0

func LabelFor(st state.Store, id state.ID) string

LabelFor is the name a person is shown for a queue: the session's alias when it has one, and Label otherwise.

Types

type ChangedError

type ChangedError struct{ ID state.ID }

ChangedError says the queue is no longer what the caller saw.

func (*ChangedError) Error

func (e *ChangedError) Error() string

type NoItemError

type NoItemError struct {
	ID state.ID
	N  int
}

NoItemError says there is no item at that position.

func (*NoItemError) Error

func (e *NoItemError) Error() string

type Queue

type Queue struct {
	Store state.Store
	Log   histlog.Log
}

Queue is the set of queues in a state folder. Log records each change once it has succeeded; the zero Log is off.

func (Queue) Add

func (q Queue) Add(id state.ID, text textsafe.Text) (int, error)

Add appends an item and returns how many items the queue now holds.

func (Queue) Count

func (q Queue) Count(id state.ID) int

Count is the number of non-empty lines.

func (Queue) Edit added in v0.6.0

func (q Queue) Edit(id state.ID, n int, text textsafe.Text, guard *string) (textsafe.Text, error)

Edit replaces the text of item n and returns the text it had. The item keeps its place.

func (Queue) Move

func (q Queue) Move(from, to state.ID, n int, guard *string) (textsafe.Text, error)

Move hands item n from one queue to the end of another and returns it. The item reaches the destination before it leaves the source, so a failure can leave a duplicate but never lose it.

func (Queue) Remove

func (q Queue) Remove(id state.ID, n int, guard *string) (textsafe.Text, error)

Remove takes item n out and returns it.

func (Queue) Reorder

func (q Queue) Reorder(id state.ID, from, to int, guard *string) (textsafe.Text, error)

Reorder moves item from to position to, and returns the item.

type RangeError

type RangeError struct {
	ID    state.ID
	Count int
}

RangeError says a position is past the end of the queue.

func (*RangeError) Error

func (e *RangeError) Error() string

Jump to

Keyboard shortcuts

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