Expand description
Core LoonFS namespace operations.
loonfs-core is the low-level API for building directly on the LoonFS
metadata protocol. Most callers should start with NamespaceEngine.
A namespace is one durable filesystem history. File bytes are written to object storage first, then metadata is published as a committed namespace mutation. Reads rebuild or reuse a verified view of the namespace before walking paths.
§Example
Commits are published as candidate batches through
publish::NamespaceCommitEngine; day-to-day reads and writes should go
through the loonfs crate’s FsReader/FsWriter handles, which wrap
this crate with caching and batching.
use loonfs_api::{AbsolutePath, CommitId, NamespaceId};
use loonfs_core::publish::{
FilesystemOperation, CommitRequest, NamespaceCommitEngine, CommitCandidate,
PublishTailOptions,
};
use loonfs_core::{BootstrapOptions, MutationContext, NamespaceEngine};
use loonfs_objectstore::local_fs_store::LocalFsStore;
let store = LocalFsStore::new(std::env::temp_dir()).expect("store");
let namespace = NamespaceId::parse("docs").expect("valid namespace id");
let engine = NamespaceEngine::builder(store)
.namespace_id(namespace.clone())
.writer_id("example-writer")
.build()
.expect("engine");
let _ = engine.bootstrap_namespace(BootstrapOptions::default());
let publish_store = LocalFsStore::new(std::env::temp_dir()).expect("store");
let context = MutationContext {
writer_id: "example-writer".to_owned(),
now_ms: 0,
};
let mut publisher = NamespaceCommitEngine::new(namespace);
let _ = publisher.publish_batch(
&publish_store,
vec![CommitCandidate::new(CommitRequest::single(
CommitId::generate(),
None,
FilesystemOperation::CreateDirectory {
path: AbsolutePath::parse("/plans").expect("path"),
parents: false,
},
))],
&context,
&PublishTailOptions::default(),
);Modules§
- cache
- Cache types and configuration for runtime read paths. Consumed by
loonfs, which owns the runtime’s cache configuration and stats, and which re-exportscache::Recencyfor the grep index’s own block cache. - commit
- Commit planning, validation, and materialization. Consumed by the
loonfspublisher and by this crate’s commit-validation integration tests. Planned commits, from planner output to durable WAL frame. - content
- Content staging and preparation-token minting. Consumed by
loonfs’s write path and its server-integrationcontent_tokensseam. Public facade over the durable content storage helpers. - control
- Typed namespace control-object loaders and verified catalog state.
Consumed by
loonfs’s cache and write paths, and re-exported asloonfs::controlfor the white-box layout assertions the server and this crate’s own tests make. - limits
- Protocol and resource ceilings. Consumed by
loonfs(re-exported to the server for request validation) and by layout tests. One source of truth for publication, verification, provider, and garbage-collection timing bounds. - metadata
- Durable metadata state and its row codecs. Public for this crate’s
white-box integration tests, which compare projected state against the
reference model;
loonfsreaches metadata only through the seams above. Materialized namespace metadata: append-only row families plus derived indexes that answer reads over them. - path
- Path parsing and current-state resolution. Consumed by
loonfs’s write path (parse_mutation_path). Path parsing, reading, and mutation planning over namespace metadata. - publish
- Commit publication types for runtime integrations. Consumed by
loonfs’s publisher, and re-exported asloonfs::publishfor the server’s filesystem handlers. - time
- The wall-clock boundary durable timestamps are stamped at. Consumed by
loonfs, whose mutation contexts and maintenance clock stamp from the same boundary this crate’s own commits do. The one wall-clock boundary durable timestamps are stamped at.
Structs§
- Begin
Direct Multipart Upload Target Response - Internal response for preparing a direct_multipart session.
- Begin
Direct PutUpload Target Response - Internal response for preparing a direct_put session before URL signing.
- Bootstrap
Options - Options for namespace bootstrap.
- Checkpoint
File - One file visible in the checkpointed state, with the content the checkpoint pinned for it.
- Checkpoint
Files Page - One page of the files a checkpoint pins.
- Checkpoint
Files Page Cursor - Where a file enumeration resumes: strictly after this inode id.
- Current
File State - What one inode looks like in the namespace’s current state.
- Delete
Namespace Options - Options for namespace deletion.
- Direct
Download Target - Where one file’s bytes actually live, for a host that is about to authorize a client to read them without passing them through itself.
- Direct
Multipart Upload Target - Internal target used by server integrations before they mint part URLs.
- Direct
PutUpload Target - Internal target used by server integrations before they mint a presigned URL.
- File
Content Stream - One file’s current content, read as fixed-size ranged chunks.
- GcConfig
- The grace window for the sweep (format spec, “Garbage collection”). It is
wall-clock cleanup policy, never a validity input, and the default is
conservative: every object gets one hour of unconditional protection.
Abandoned fork records are not under it — a fork attempt carries its own
lease, and letting that pass is the whole proof
(
gc/fork_checkpoints.rs) — and neither are upload sessions or the content they leave behind: a session carries its own lease, and the window a completed session’s content is protected for is derived inlimits, not configured. - Metadata
Reorganize Report - Multipart
Part Target - One part a server integration is about to sign.
- Multipart
Part Targets - Everything a server integration needs to sign one wave of part uploads.
- Mutation
Context - Namespace
Engine - A namespace-scoped core API.
- Namespace
Engine Builder - Builder for
NamespaceEngine. - Pass
Budget - The work one garbage-collection pass is allowed to do.
- Runtime
Read Context - The pinned inputs the runtime resolves once per read: the head anchored to its manifest, the shared caches, and (when the runtime has it) the namespace’s immutable catalog pair.
- Writer
Fence - The fencing event a writer session observed: the epoch the session held, the epoch that displaced it, and — when the head recorded a writer block — the winner’s label and when it acquired.
Enums§
- Aged
Sweep - What aging one unreferenced candidate decided.
- Bootstrap
Namespace Error - Error
- Public error type returned by
loonfs-core. - Error
Code - Stable machine-readable error reason.
- Error
Kind - Broad error category for caller or operator action.
- Metadata
Projection Load Error - Failures while loading a bounded manifest-plus-tail metadata projection.
- Metadata
Reorganize Outcome - What one reorganization step did.
- Metadata
View Error - Failures specific to manifest-plus-tail metadata views.
- Namespace
Engine Build Error - Error returned when a
NamespaceEnginecannot be built. - Store
Failure Class - What a failed provider operation says about who can fix it, preserved across the message-flattening seams so the wire code can distinguish “fix the storage credentials” from “unclassified internal failure”.
Constants§
- CONTENT_
READ_ CHUNK_ BYTES - Bytes one ranged read of a content object fetches, and therefore the most of that object a streaming read holds at once.
- MAX_
RESOLVE_ CURRENT_ FILES - The most inode ids [
resolve_current_files] answers in one call.
Functions§
- delete_
if_ aged - Deletes one unreferenced candidate if the grace window has passed over it, and says what it decided otherwise.
- gc_
namespace