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

spool

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTTL     = 24 * time.Hour
	DefaultMaxSize = 2 * 1024 * 1024 * 1024 // 2 GB
	DefaultDir     = ""                     // empty = os.TempDir()/duckdb-kernel
)

Default configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.2.0

type Config struct {
	Dir     string        // spool directory (default: /tmp/duckdb-kernel)
	TTL     time.Duration // max file age (default: 24h)
	MaxSize int64         // max total disk usage in bytes (default: 2GB)
}

Config holds spool configuration.

type Spool

type Spool struct {
	Dir           string
	PersistentDir string // optional, set via config or Pin()
	TTL           time.Duration
	MaxSize       int64
}

Spool manages Arrow IPC files on disk. Flat directory structure — no session nesting. Files are named {queryID}.arrow. TTL-based cleanup + disk size limit.

Supports two directories:

  • Dir (volatile): /tmp/duckdb-kernel/ — TTL cleanup, auto-managed
  • PersistentDir (optional): .duckdb-results/ — user-pinned results, no TTL

func NewSpool

func NewSpool(cfg Config) (*Spool, error)

NewSpool creates a spool with the given config. Creates the directory if it doesn't exist. Runs initial cleanup (delete expired files, enforce size limit).

func (*Spool) Cleanup

func (s *Spool) Cleanup() (int, error)

Cleanup deletes expired files and enforces disk size limit. Returns the number of files deleted.

func (*Spool) Exists added in v0.2.0

func (s *Spool) Exists(queryID string) bool

Exists checks if a spool file exists for the given query ID.

func (*Spool) IsPinned added in v0.2.0

func (s *Spool) IsPinned(queryID string) bool

IsPinned checks if a query result is in the persistent dir.

func (*Spool) ListFiles added in v0.2.0

func (s *Spool) ListFiles() ([]string, error)

ListFiles returns all .arrow file names (without extension) in the spool dir.

func (*Spool) NewStreamWriter added in v0.1.1

func (s *Spool) NewStreamWriter(queryID string) (*StreamWriter, error)

NewStreamWriter creates a streaming IPC writer for the given query.

func (*Spool) OpenReader added in v0.1.1

func (s *Spool) OpenReader(queryID string) (*ipc.Reader, io.Closer, error)

OpenReader opens a streaming IPC reader for the given query. Checks persistent dir first (pinned results), then volatile dir.

func (*Spool) Path

func (s *Spool) Path(queryID string) string

Path returns the Arrow IPC file path for a given query ID.

func (*Spool) Pin added in v0.2.0

func (s *Spool) Pin(queryID string) error

Pin copies an Arrow file from volatile dir to persistent dir. Idempotent: returns nil if already pinned. Creates persistent dir and .gitignore if needed.

func (*Spool) Remove added in v0.1.2

func (s *Spool) Remove(queryID string) error

Remove deletes a single spool file by query ID (from both dirs).

func (*Spool) TotalSize added in v0.2.0

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

TotalSize returns the total size of all files in the spool dir.

func (*Spool) Unpin added in v0.2.0

func (s *Spool) Unpin(queryID string) error

Unpin moves an Arrow file from persistent dir back to volatile dir.

type StreamWriter added in v0.1.1

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

StreamWriter writes Arrow record batches to an IPC streaming file.

func (*StreamWriter) Close added in v0.1.1

func (sw *StreamWriter) Close() error

Close flushes and closes the IPC stream and underlying file.

func (*StreamWriter) Write added in v0.1.1

func (sw *StreamWriter) Write(rec arrow.RecordBatch) error

Write writes a single record batch to the IPC stream.

Jump to

Keyboard shortcuts

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