Documentation
¶
Index ¶
- Constants
- Variables
- type Compactor
- type Engine
- type EngineStore
- type Entry
- type FileChunkUpdate
- type Kind
- type LogEngine
- func (e *LogEngine) Close() error
- func (e *LogEngine) Compact(ctx context.Context) error
- func (e *LogEngine) CompactAsync(ctx context.Context) <-chan error
- func (e *LogEngine) Sync(ctx context.Context) error
- func (e *LogEngine) Update(ctx context.Context, fn func(Tx) error) error
- func (e *LogEngine) View(ctx context.Context, fn func(ReadTx) error) error
- type LogOptions
- type MemoryEngine
- type Namespace
- func (n *Namespace) ClearChunks(ctx context.Context, inode uint64, first, count int) ([]chunk.Ref, error)
- func (n *Namespace) Create(ctx context.Context, parent uint64, name string, kind Kind, mode uint32, ...) (Entry, error)
- func (n *Namespace) Get(inode uint64) (Entry, error)
- func (n *Namespace) GetChunk(inode uint64, index int) (Entry, chunk.Ref, error)
- func (n *Namespace) List(parent uint64) ([]Entry, error)
- func (n *Namespace) Load(ctx context.Context) error
- func (n *Namespace) Lookup(parent uint64, name string) (Entry, error)
- func (n *Namespace) Modify(ctx context.Context, inode uint64, change func(*Entry) error) (Entry, error)
- func (n *Namespace) Remove(ctx context.Context, inode uint64) error
- func (n *Namespace) Rename(ctx context.Context, inode, newParent uint64, newName string) error
- func (n *Namespace) RenameReplace(ctx context.Context, inode, newParent uint64, newName string) (Entry, error)
- func (n *Namespace) ReplaceChunk(ctx context.Context, inode uint64, index int, expected, replacement chunk.Ref) (bool, error)
- func (n *Namespace) Snapshot() Snapshot
- func (n *Namespace) Store() *EngineStore
- func (n *Namespace) Update(ctx context.Context, entry Entry) error
- func (n *Namespace) UpdateFileChunk(ctx context.Context, inode uint64, update FileChunkUpdate) ([]chunk.Ref, error)
- type ReadTx
- type Snapshot
- type Store
- type SyncPolicy
- type Syncer
- type Tx
Constants ¶
const CurrentVersion = 1
Variables ¶
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") )
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.
type FileChunkUpdate ¶
FileChunkUpdate commits attributes and at most one chunk. Index -1 changes attributes/length only. Count bounds the logical manifest after truncation.
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.
type LogOptions ¶
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
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 (*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) GetChunk ¶
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) 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) 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) Store ¶
func (n *Namespace) Store() *EngineStore
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 ¶
func NewSnapshot ¶
func NewSnapshot() Snapshot
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 )