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
- Variables
- func Label(id state.ID) string
- func LabelFor(st state.Store, id state.ID) string
- type ChangedError
- type NoItemError
- type Queue
- func (q Queue) Add(id state.ID, text textsafe.Text) (int, error)
- func (q Queue) Count(id state.ID) int
- func (q Queue) Edit(id state.ID, n int, text textsafe.Text, guard *string) (textsafe.Text, error)
- func (q Queue) Move(from, to state.ID, n int, guard *string) (textsafe.Text, error)
- func (q Queue) Remove(id state.ID, n int, guard *string) (textsafe.Text, error)
- func (q Queue) Reorder(id state.ID, from, to int, guard *string) (textsafe.Text, error)
- type RangeError
Constants ¶
const MaxFileBytes = 4 << 20
MaxFileBytes is how large a queue file may grow by adding: the reader keeps 8 MiB, and a file past that would lose its end the next time it is rewritten.
const MaxItem = 200
MaxItem is the longest item, in characters.
Variables ¶
var ErrBlank = errors.New("nothing to queue")
ErrBlank says the text to queue holds nothing.
var ErrEmpty = errors.New("queue empty")
ErrEmpty says the queue has no items.
var ErrFull = errors.New("queue full: remove some items first")
ErrFull says a queue file has reached MaxFileBytes.
Functions ¶
Types ¶
type ChangedError ¶
ChangedError says the queue is no longer what the caller saw.
func (*ChangedError) Error ¶
func (e *ChangedError) Error() string
type NoItemError ¶
NoItemError says there is no item at that position.
func (*NoItemError) Error ¶
func (e *NoItemError) Error() string
type Queue ¶
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) Edit ¶ added in v0.6.0
Edit replaces the text of item n and returns the text it had. The item keeps its place.
func (Queue) Move ¶
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.
type RangeError ¶
RangeError says a position is past the end of the queue.
func (*RangeError) Error ¶
func (e *RangeError) Error() string