meta

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const CurrentVersion = 1

Variables

View Source
var (
	ErrExists       = errors.New("metadata entry already exists")
	ErrNotDirectory = errors.New("metadata parent is not a directory")
	ErrIsDirectory  = errors.New("metadata entry is a directory")
	ErrNotEmpty     = errors.New("metadata directory is not empty")
	ErrInvalidName  = errors.New("metadata entry name is invalid")
	ErrRootMutation = errors.New("metadata root cannot be mutated")
	ErrInvalidMove  = errors.New("metadata directory cannot be moved into itself")
)
View Source
var ErrNotFound = errors.New("metadata record not found")

Functions

This section is empty.

Types

type Compactor

type Compactor interface {
	Compact(ctx context.Context) error
	CompactAsync(ctx context.Context) <-chan error
}

Compactor is implemented by engines that can asynchronously reclaim old log records without changing the namespace API.

type Engine

type Engine interface {
	View(ctx context.Context, fn func(ReadTx) error) error
	Update(ctx context.Context, fn func(Tx) error) error
	Close() error
}

Engine is the extension point for metadata persistence. Implementations may be append-only local logs, embedded databases, or remote transactional stores. Values are binary records; the namespace layer owns their encoding.

type EngineStore

type EngineStore struct {
	Engine Engine
}

EngineStore persists namespace entries as independent binary records inside an Engine. It does not serialize the complete namespace as JSON or rewrite a monolithic manifest for every write.

func NewStore

func NewStore(ctx context.Context, engine Engine) (*EngineStore, error)

func (*EngineStore) Apply

func (s *EngineStore) Apply(ctx context.Context, puts []Entry, deletes []uint64, nextInode uint64) error

Apply appends only the changed records. It is the write path used by the FUSE namespace; unchanged entries are never rewritten.

func (*EngineStore) Load

func (s *EngineStore) Load(ctx context.Context) (Snapshot, error)

func (*EngineStore) Save

func (s *EngineStore) Save(ctx context.Context, snapshot Snapshot) error

type Entry

type Entry struct {
	Inode   uint64
	Parent  uint64
	Name    string
	Kind    Kind
	Mode    uint32
	UID     uint32
	GID     uint32
	Size    int64
	ModTime time.Time
	Chunks  []chunk.Ref
}

type FileChunkUpdate

type FileChunkUpdate struct {
	Size    int64
	ModTime time.Time
	Count   int
	Index   int
	Ref     chunk.Ref
}

FileChunkUpdate commits attributes and at most one chunk. Index -1 changes attributes/length only. Count bounds the logical manifest after truncation.

type Kind

type Kind uint8
const (
	KindDirectory Kind = 1
	KindFile      Kind = 2
)

type LogEngine

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

LogEngine is an append-only metadata engine. Transactions append one checksummed binary batch to a sequential log and update an in-memory index. Recovery replays complete batches and truncates an incomplete tail left by a crash, so a partially written multi-key transaction is never published.

func OpenLog

func OpenLog(path string, options LogOptions) (*LogEngine, error)

func (*LogEngine) Close

func (e *LogEngine) Close() error

func (*LogEngine) Compact

func (e *LogEngine) Compact(ctx context.Context) error

Compact rewrites only the current key/value state into a new log. Callers can run CompactAsync from a maintenance goroutine; normal updates are briefly serialized while the active log is swapped.

func (*LogEngine) CompactAsync

func (e *LogEngine) CompactAsync(ctx context.Context) <-chan error

func (*LogEngine) Sync

func (e *LogEngine) Sync(ctx context.Context) error

func (*LogEngine) Update

func (e *LogEngine) Update(ctx context.Context, fn func(Tx) error) error

func (*LogEngine) View

func (e *LogEngine) View(ctx context.Context, fn func(ReadTx) error) error

type LogOptions

type LogOptions struct {
	Mode           os.FileMode
	SyncPolicy     SyncPolicy
	SyncInterval   time.Duration
	StrictRecovery bool
}

type MemoryEngine

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

MemoryEngine is a transactional in-memory Engine for tests and ephemeral mounts.

func NewMemoryEngine

func NewMemoryEngine() *MemoryEngine

func (*MemoryEngine) Close

func (e *MemoryEngine) Close() error

func (*MemoryEngine) Update

func (e *MemoryEngine) Update(ctx context.Context, fn func(Tx) error) error

func (*MemoryEngine) View

func (e *MemoryEngine) View(ctx context.Context, fn func(ReadTx) error) error

type Namespace

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

Namespace is the in-memory inode index backed by an append-only Engine. Lookups and directory listings do not hit the backend; mutations append only the changed records before publishing them to the index.

func OpenNamespace

func OpenNamespace(ctx context.Context, engine Engine) (*Namespace, error)

func (*Namespace) ClearChunks

func (n *Namespace) ClearChunks(ctx context.Context, inode uint64, first, count int) ([]chunk.Ref, error)

ClearChunks atomically removes chunk mappings without changing file size. It returns retired references only after the metadata transaction commits. Content-addressed backend objects may still be shared by other files.

func (*Namespace) Create

func (n *Namespace) Create(ctx context.Context, parent uint64, name string, kind Kind, mode uint32, uid, gid uint32) (Entry, error)

func (*Namespace) Get

func (n *Namespace) Get(inode uint64) (Entry, error)

func (*Namespace) GetChunk

func (n *Namespace) GetChunk(inode uint64, index int) (Entry, chunk.Ref, error)

GetChunk returns inode attributes and one reference without copying the full file manifest. The returned Entry has no Chunks; negative indexes return attributes only. Hot raw-cache range reads should use this bounded lookup.

func (*Namespace) List

func (n *Namespace) List(parent uint64) ([]Entry, error)

func (*Namespace) Load

func (n *Namespace) Load(ctx context.Context) error

func (*Namespace) Lookup

func (n *Namespace) Lookup(parent uint64, name string) (Entry, error)

func (*Namespace) Modify

func (n *Namespace) Modify(ctx context.Context, inode uint64, change func(*Entry) error) (Entry, error)

Modify changes the latest inode atomically. Background chunk replacement must not overwrite a concurrent write, rename, chmod, or truncation.

func (*Namespace) Remove

func (n *Namespace) Remove(ctx context.Context, inode uint64) error

func (*Namespace) Rename

func (n *Namespace) Rename(ctx context.Context, inode, newParent uint64, newName string) error

func (*Namespace) RenameReplace

func (n *Namespace) RenameReplace(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)

RenameReplace atomically moves an entry, replacing an existing compatible target. It returns the removed entry, or an entry with Inode zero if absent. The caller retires removed references after the transaction is durable.

func (*Namespace) ReplaceChunk

func (n *Namespace) ReplaceChunk(ctx context.Context, inode uint64, index int, expected, replacement chunk.Ref) (bool, error)

ReplaceChunk atomically replaces exactly one expected reference. It leaves attributes and other chunk slots untouched, including concurrent changes.

func (*Namespace) Snapshot

func (n *Namespace) Snapshot() Snapshot

func (*Namespace) Store

func (n *Namespace) Store() *EngineStore

func (*Namespace) Update

func (n *Namespace) Update(ctx context.Context, entry Entry) error

func (*Namespace) UpdateFileChunk

func (n *Namespace) UpdateFileChunk(ctx context.Context, inode uint64, update FileChunkUpdate) ([]chunk.Ref, error)

UpdateFileChunk avoids copying and diffing a growing file manifest for each chunk. Retired references are returned only after the transaction commits.

type ReadTx

type ReadTx interface {
	Get(bucket, key []byte) ([]byte, error)
	ForEach(bucket, prefix []byte, fn func(key, value []byte) error) error
}

ReadTx is a read-only transaction over named binary buckets.

type Snapshot

type Snapshot struct {
	Version   int
	NextInode uint64
	Entries   map[uint64]Entry
}

func NewSnapshot

func NewSnapshot() Snapshot

func (Snapshot) Validate

func (s Snapshot) Validate() error

type Store

type Store interface {
	Load(ctx context.Context) (Snapshot, error)
	Save(ctx context.Context, snapshot Snapshot) error
}

Store is the high-level metadata persistence contract used by the daemon.

type SyncPolicy

type SyncPolicy uint8
const (
	SyncAlways SyncPolicy = iota + 1
	SyncInterval
	SyncNever
)

type Syncer

type Syncer interface {
	Sync(ctx context.Context) error
}

Syncer is implemented by engines that can force their durable state.

type Tx

type Tx interface {
	ReadTx
	Put(bucket, key, value []byte) error
	Delete(bucket, key []byte) error
}

Tx is an atomic read/write metadata transaction.

Jump to

Keyboard shortcuts

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