spool

package
v0.2.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0, Apache-2.0 Imports: 10 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 spool stores unacked frames on disk until the server acks them.

Vendored from bot-agent internal/agent/spool (Apache-2.0, see ../NOTICE). DD changes: ids are worker protocol ids (workerproto.ValidID) instead of UUIDs; a full spool refuses the new frame (ErrFull) instead of dropping the oldest one, because the worker protocol must never lose an unacked frame; age is no longer enforced on Put or List but by DropOlderThan, which the worker calls only for jobs that already ended (protocol v1 §6.1); Bytes reports the directory's size for the worker-wide cap.

Index

Constants

This section is empty.

Variables

View Source
var ErrFull = errors.New("spool full")

ErrFull is returned by Put when the frame does not fit under the cap.

Functions

func FrameBytes

func FrameBytes(v any) ([]byte, error)

FrameBytes is a small helper for tests that want a stable body.

Types

type Item

type Item struct {
	ID    string
	Seq   int64
	Frame json.RawMessage
	At    time.Time
}

Item is one stored batch, in send order.

type Spool

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

Spool is the $STATE_DIR/spool directory.

func Open

func Open(stateDir string) (*Spool, error)

Open creates dir/spool mode 0700 and uses the contract cap.

func OpenLimited

func OpenLimited(stateDir string, maxBytes int64) (*Spool, error)

OpenLimited is Open with an explicit cap.

func (*Spool) Bytes

func (s *Spool) Bytes() (int64, error)

Bytes is the size of the stored entries.

func (*Spool) Delete

func (s *Spool) Delete(id string) error

Delete removes an acked entry. A missing file is not an error.

func (*Spool) DropOlderThan

func (s *Spool) DropOlderThan(maxAge time.Duration, now time.Time) error

DropOlderThan removes entries queued more than maxAge before now.

func (*Spool) List

func (s *Spool) List() ([]Item, error)

List returns unacked entries in put order.

func (*Spool) Put

func (s *Spool) Put(id string, frame []byte, at time.Time) error

Put stores frame under id, replacing an entry with the same id. The file mode is 0600. A frame that would take the directory over the cap is refused with ErrFull; nothing is dropped.

Jump to

Keyboard shortcuts

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