capacitygate

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package capacitygate provides preflight free-space checks for operations that materialize save point payloads before mutating public state.

Index

Constants

View Source
const (
	ErrCode                  = "E_NOT_ENOUGH_SPACE"
	DefaultSafetyMarginBytes = 16 << 20
)

Variables

This section is empty.

Functions

func TreeSize

func TreeSize(root string, exclude func(rel string) bool) (int64, error)

func TreeSizeWithin

func TreeSizeWithin(baseRoot, relPath string, exclude func(rel string) bool) (int64, error)

Types

type Component

type Component struct {
	Name  string
	Path  string
	Bytes int64
}

type Decision

type Decision struct {
	RequiredBytes     int64
	SafetyMarginBytes int64
	AvailableBytes    int64
	ShortfallBytes    int64
	ProbePath         string
}

type DeviceMeter

type DeviceMeter interface {
	Meter
	DeviceID(path string) (string, error)
}

type Gate

type Gate struct {
	Meter             Meter
	SafetyMarginBytes int64
}

func Default

func Default() Gate

func (Gate) Check

func (g Gate) Check(req Request) (*Decision, error)

type InsufficientError

type InsufficientError struct {
	Request  Request
	Decision Decision
}

func (*InsufficientError) As

func (e *InsufficientError) As(target any) bool

func (*InsufficientError) Error

func (e *InsufficientError) Error() string

type Meter

type Meter interface {
	AvailableBytes(path string) (int64, error)
}

type Request

type Request struct {
	Operation       string
	Folder          string
	Workspace       string
	SourceSavePoint string
	Path            string
	Components      []Component
	FailureMessages []string
}

type StatfsMeter

type StatfsMeter struct{}

func (StatfsMeter) AvailableBytes

func (StatfsMeter) AvailableBytes(path string) (int64, error)

func (StatfsMeter) DeviceID

func (StatfsMeter) DeviceID(path string) (string, error)

Jump to

Keyboard shortcuts

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