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
- func Module(name foundation.ProviderID, key foundation.Key[*Backend], config Config) foundation.Module
- type Backend
- func (b *Backend) Capabilities() storage.Capabilities
- func (b *Backend) Close() error
- func (b *Backend) Copy(ctx context.Context, source, target storage.ObjectKey, ...) (storage.ObjectInfo, error)
- func (b *Backend) Delete(ctx context.Context, key storage.ObjectKey, options storage.DeleteOptions) (err error)
- func (b *Backend) List(ctx context.Context, options storage.ListOptions) (storage.Page, error)
- func (b *Backend) Locate(key storage.ObjectKey) (storage.ObjectAddress, error)
- func (b *Backend) Open(ctx context.Context, key storage.ObjectKey, options storage.ReadOptions) (io.ReadCloser, storage.ReadInfo, error)
- func (b *Backend) Prune(ctx context.Context, olderThan time.Time, limit int) (uint64, error)
- func (b *Backend) Put(ctx context.Context, key storage.ObjectKey, source io.Reader, ...) (storage.ObjectInfo, error)
- func (b *Backend) Start(ctx context.Context) error
- func (b *Backend) Stat(ctx context.Context, key storage.ObjectKey, options storage.ReadOptions) (storage.ObjectInfo, error)
- type Config
Constants ¶
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 Prepare ¶
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 ¶
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 ¶
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 ¶
Locate returns the managed store identity and literal key without object I/O.
func (*Backend) Open ¶
func (b *Backend) Open(ctx context.Context, key storage.ObjectKey, options storage.ReadOptions) (io.ReadCloser, storage.ReadInfo, error)
Open returns an owned reader for the selected span after checking the validator; close the reader after use.
func (*Backend) Prune ¶
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 ¶
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.
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 ¶
DefaultConfig returns bounded, synchronous storage settings rooted at root.