local

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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
}

Backend owns a confined managed store root; prepare and start it before use, then close it after its disks drain.

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

Capabilities returns support for ranges, conditional operations and delimited listings.

func (*Backend) Close

func (b *Backend) Close() error

Close closes the managed root once; callers must drain all disks using it first.

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)

Delete removes a record under its key lock; absent unconditional targets succeed and mismatched validators conflict.

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)

Locate returns the managed store identity and literal key without object I/O.

func (*Backend) Open

Open returns an owned reader for the selected span after checking the validator; close the reader after use.

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)

Put streams the borrowed source into a staged record and publishes it under the write condition.

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

Stat returns complete record metadata, rejecting ranges and closing the temporary record reader.

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
}

Config sets the trusted store root, object and scan bounds, durability syncing and clock.

func DefaultConfig

func DefaultConfig(root string) Config

DefaultConfig returns bounded, synchronous storage settings rooted at root.

func (Config) Validate

func (c Config) Validate() error

Validate checks the absolute root, bounds, clock and supported host platform without filesystem I/O.

Jump to

Keyboard shortcuts

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