spool

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package spool owns the directory where upload handlers stage request bodies, so a crash cannot leave unbounded orphan files and one upload cannot fill the disk.

Index

Constants

This section is empty.

Variables

View Source
var ErrQuota = errors.New("spool: quota exceeded")

ErrQuota is returned by Create when the spool already holds its byte quota.

Functions

func Create

func Create(kind string) (*os.File, error)

Create opens a new spool file, refusing when the quota is already used up.

func Dir

func Dir() string

Dir returns the spool directory, created on demand. Only files with our prefix are ever counted or swept, so sharing the OS temp dir is safe.

func MaxAge

func MaxAge() time.Duration

MaxAge is how old a spool file must be before the sweeper treats it as an orphan.

func Quota

func Quota() int64

Quota is the byte cap for the whole spool; 0 means unlimited.

func SetMaxAge

func SetMaxAge(secs int64)

SetMaxAge sets the orphan age in seconds at runtime; 0 reverts to env.

func SetQuota

func SetQuota(bytes int64)

SetQuota sets the quota in bytes at runtime; 0 reverts to env.

func Sweep

func Sweep() int

Sweep removes spool files older than MaxAge and returns how many it deleted.

Types

type Stats

type Stats struct {
	Files      int   `json:"files"`
	Bytes      int64 `json:"bytes"`
	QuotaBytes int64 `json:"quota_bytes"`
	Orphans    int   `json:"orphans"`
}

Stats is the spool state shown in control plane health.

func Usage

func Usage() Stats

Usage walks the spool once. Orphans are files older than MaxAge.

Jump to

Keyboard shortcuts

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