workspace

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manages multiple workspaces and selects the best one for each upload

func NewManager

func NewManager(tmpdirFlag string, capacityThreshold float64) (*Manager, error)

NewManager creates a new workspace manager from a comma-separated list of directories capacityThreshold specifies the safety margin multiplier (e.g., 4.0 requires 4x file size available)

func (*Manager) CreateTempFile

func (m *Manager) CreateTempFile(fileSize uint64, prefix string) (*os.File, error)

CreateTempFile creates a temporary file in the selected workspace

func (*Manager) GetAllPaths

func (m *Manager) GetAllPaths() []string

GetAllPaths returns all workspace paths

func (*Manager) GetPrimaryPath

func (m *Manager) GetPrimaryPath() string

GetPrimaryPath returns the fastest workspace path (used for non-upload temp files)

func (*Manager) GetStats

func (m *Manager) GetStats() []Stats

GetStats returns statistics about all workspaces

func (*Manager) SelectWorkspace

func (m *Manager) SelectWorkspace(fileSize uint64) (*Workspace, error)

SelectWorkspace selects the best workspace for a file of the given size Strategy: Use the fastest workspace that has at least capacityThreshold x file size available

type Stats

type Stats struct {
	Path           string
	WriteMBps      float64
	AvailableBytes uint64
	TotalBytes     uint64
	LastChecked    time.Time
}

Stats returns statistics about all workspaces

type Workspace

type Workspace struct {
	Path           string
	WriteMBps      float64 // Write throughput in MB/s
	LastChecked    time.Time
	AvailableBytes uint64
	TotalBytes     uint64
	// contains filtered or unexported fields
}

Workspace represents a temporary file storage location with its performance characteristics

func (*Workspace) Benchmark

func (ws *Workspace) Benchmark() error

Benchmark tests the write performance of this workspace

func (*Workspace) GetAvailableBytes

func (ws *Workspace) GetAvailableBytes() uint64

GetAvailableBytes returns the currently known available space (thread-safe)

func (*Workspace) UpdateCapacity

func (ws *Workspace) UpdateCapacity() error

UpdateCapacity checks the available disk space for this workspace

Jump to

Keyboard shortcuts

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