local

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package local implements a managed, crash-aware object store under an os.Root. Keys are independent of host filenames. Each published file atomically holds one binary header, complete metadata and payload; temporary files are hidden.

Index

Constants

View Source
const MaxPrune = 256

Variables

This section is empty.

Functions

func Module

func Module(name foundation.ProviderID, key foundation.Key[*Backend], config Config) foundation.Module

Module prepares an adapter without I/O and opens its root during boot. Disk modules must require this provider so their readers drain before root cleanup.

Types

type Backend

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

func Open

func Open(ctx context.Context, config Config) (*Backend, error)

Open is Prepare followed by Start for callers that explicitly own the adapter.

func Prepare

func Prepare(config Config) (*Backend, error)

Prepare validates configuration without filesystem I/O. Start initializes or reopens the store during application boot; a closed backend cannot restart.

func (*Backend) Capabilities

func (b *Backend) Capabilities() storage.Capabilities

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) Copy

func (b *Backend) Copy(ctx context.Context, source, target storage.ObjectKey, options storage.CopyOptions, maximum int64) (storage.ObjectInfo, error)

Copy implements storage.ServerCopier within one managed store. It writes a new record (the header binds its key) and copies the payload file-to-file, which uses kernel copy offload where the platform provides it, never the disk's streaming read path. The source is pinned by its validator and the destination publishes with the same condition checks as Put.

func (*Backend) Delete

func (b *Backend) Delete(ctx context.Context, key storage.ObjectKey, options storage.DeleteOptions) (err error)

func (*Backend) List

func (b *Backend) List(ctx context.Context, options storage.ListOptions) (storage.Page, error)

List scans the bounded store and keeps the smallest Limit+1 entries after the cursor. Unreadable or mismatched records are counted in Skipped rather than failing the page; staging and control files are never listed.

func (*Backend) Locate

func (b *Backend) Locate(key storage.ObjectKey) (storage.ObjectAddress, error)

func (*Backend) Open

func (*Backend) Prune

func (b *Backend) Prune(ctx context.Context, olderThan time.Time, limit int) (uint64, error)

Prune removes only recognized, old staging files whose live-writer lock can be acquired. A slow upload is never removed merely because it is old. A crash releases its file lock. Published objects and marker/lock files are untouched. limit bounds deletion; Config.MaxScan independently bounds scanning work.

func (*Backend) Put

func (b *Backend) Put(ctx context.Context, key storage.ObjectKey, source io.Reader, options storage.PutOptions) (storage.ObjectInfo, error)

func (*Backend) Start

func (b *Backend) Start(ctx context.Context) error

Start takes ownership of an existing empty directory or reopens a previously initialized Foundry store. It never imports, wipes or overwrites an unrelated directory. The root must be controlled by trusted operators, not upload users. New files/directories use 0600/0700. Close all Disk operations before Close.

func (*Backend) Stat

type Config

type Config struct {
	Root           string
	MaxObjectBytes int64
	// MaxScan bounds files examined by one lexical listing or cleanup call. No
	// incomplete listing is returned when this budget is exhausted.
	MaxScan int
	Sync    bool
	Clock   clock.Clock
}

func DefaultConfig

func DefaultConfig(root string) Config

func (Config) Validate

func (c Config) Validate() error

Jump to

Keyboard shortcuts

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