lode

module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0

README

Lode

Structured persistence for object storage.

Go Reference Release CI License Documentation

Lode is an embeddable Go persistence framework that provides snapshots, metadata, and safe write semantics on object storage, without requiring a database. It offers Datasets, which hold structured collections of named objects, and Volumes, which store sparse, resumable byte ranges and reside in an experimental package (lode/volume).


Quick Start

Install
go get github.com/pithecene/lode
Writing and Reading a Blob
package main

import (
    "context"
    "fmt"
    "github.com/pithecene/lode/lode"
)

func main() {
    ctx := context.Background()

    // Open a root over filesystem storage, and a blob dataset in it.
    blobs, _ := lode.Open(lode.FS("/tmp/lode-demo")).Blobs(ctx, "mydata")

    // Write a blob: one []byte per snapshot.
    snap, _ := blobs.Write(ctx, []byte("hello world"), lode.D{"source": "demo"})
    fmt.Println("Created snapshot:", snap.ID)

    // Read the blob back.
    data, _ := blobs.Read(ctx, snap.ID)
    fmt.Println("Data:", string(data))
}
Writing Structured Records
// The codec fixes the record type: here Event, encoded as JSON Lines.
type Event struct {
    ID    int    `json:"id"`
    Event string `json:"event"`
    Day   string `json:"day"`
}

// Batch is the snapshot's metadata.
type Batch struct {
    Number int `json:"number"`
}

root := lode.Open(lode.FS("/tmp/lode-demo"))
events, _ := root.Records(ctx, "events", lode.JSONL[Event](),
    lode.WithLayout(lode.Hive("day").By(func(e Event) lode.Partition {
        return lode.Partition{"day": e.Day}
    })))

snap, _ := events.Write(ctx, []Event{
    {ID: 1, Event: "signup", Day: "2026-10-22"},
    {ID: 2, Event: "login", Day: "2026-10-22"},
}, Batch{Number: 1})
got, _ := events.Read(ctx, snap.ID) // []Event

var batch Batch
_ = snap.Metadata.Decode(&batch)

// A reader opens a view: it takes the layout from the manifests.
view, _ := lode.OpenReadOnly(lode.FS("/tmp/lode-demo")).Records(ctx, "events", lode.JSONL[Event]())

Lode stores data on the filesystem (lode.FS), in memory (lode.Memory), or on S3-compatible storage (s3.Factory). The storage location must exist before the caller opens a dataset (see Storage Prerequisites). PUBLIC_API.md describes streaming writes and the experimental Volume API, and examples/ contains complete programs.


Core Ideas

A Dataset, which holds structured collections, follows these rules:

  • Each write produces a new, immutable snapshot.
  • Each snapshot references a manifest that describes its data files and metadata.
  • A caller chooses storage, format, compression, and partitioning independently of one another.

A Volume, which stores sparse byte ranges and resides in the experimental package lode/volume, follows these rules:

  • A Volume is a sparse, resumable byte address space.
  • Commits record which ranges exist, and Lode never fills a gap with zeros.
  • Each commit produces a cumulative manifest.

Datasets and Volumes share these rules:

  • A snapshot becomes visible only after Lode persists its manifest.
  • Lode persists the metadata that the caller supplies and never infers metadata.
  • Every store detects concurrent writers through compare-and-swap (CAS).

Guarantees

  • Immutable snapshots: Lode never modifies a data file or manifest after it persists the object.
  • Atomic commits: a snapshot is visible only once its manifest exists.
  • Explicit metadata: every snapshot carries metadata that the caller supplies, and Lode never infers metadata.
  • Safe writes: Lode never overwrites an existing object, and every store detects concurrent writers through CAS.

Lode does not coordinate distributed writers, execute queries, compact data, or delete objects unless the caller requests deletion. The concepts guide defines each guarantee and each exclusion.

Lode has two limitations by design. A backend that lacks conditional writes supports writers in one process only, through SingleProcess, so writers in separate processes require external coordination (Concurrency and CAS). On an S3-compatible service other than AWS S3, the guarantees depend on conditional writes and consistency that Lode does not verify (Other S3-Compatible Services).


Documentation

Pithecene publishes the guides, the public API reference, and the contracts at pithecene.sh/docs/lode. The repository holds the same documents:

Topic Where
Storage model, commits, and write API selection Concepts guide
Rules of the API that most often surprise a caller Usage pitfalls guide
Complete API usage and options PUBLIC_API.md
Expiring snapshots and reclaiming residual data Retention guide
Snapshot ID format and ordering Snapshot ID guide
Normative behavior docs/contracts/
Runnable programs examples/
Performance docs/BENCHMARKS.md
Documentation conventions, for maintainers docs/maintainers/

Status

The current release of Lode is v0.13.0. docs/plans/V1_API_DECISIONS.md lists the breaking changes still under consideration for v1.0, and CHANGELOG.md describes each release.


License

Pithecene LLC distributes Lode under the Apache License 2.0 (see LICENSE). Copyright © 2026 Pithecene LLC.

Pithecene answers inquiries at contact@pithecene.sh. SECURITY.md describes the procedure for reporting a vulnerability.

Directories

Path Synopsis
examples
blob_upload command
Example: Blob Upload (Raw Bytes)
Example: Blob Upload (Raw Bytes)
default_layout command
Example: Default Layout Round-Trip
Example: Default Layout Round-Trip
hive_layout command
Example: Hive Layout Round-Trip
Example: Hive Layout Round-Trip
manifest_driven command
Example: Manifest-Driven Discovery
Example: Manifest-Driven Discovery
optimistic_concurrency command
Example: CAS Optimistic Concurrency
Example: CAS Optimistic Concurrency
parquet command
Example: Parquet Codec Round-Trip
Example: Parquet Codec Round-Trip
retention command
Example: Retention — expire runs, then sweep
Example: Retention — expire runs, then sweep
s3 command
Example: S3 Storage Adapter
Example: S3 Storage Adapter
stream_write_records command
Example: Records.StreamWrite — Streaming Record Writes
Example: Records.StreamWrite — Streaming Record Writes
vector_artifacts command
Example: Vector Artifact Pipeline
Example: Vector Artifact Pipeline
volume_sparse command
Example: Sparse Volume Ranges
Example: Sparse Volume Ranges
internal
apidoc
Package apidoc holds the test that keeps PUBLIC_API.md in step with the exported surface: every exported top-level identifier of the public packages appears in the document's code, and every identifier that the document qualifies with a package name exists.
Package apidoc holds the test that keeps PUBLIC_API.md in step with the exported surface: every exported top-level identifier of the public packages appears in the document's code, and every identifier that the document qualifies with a package name exists.
chaos
Package chaos is a randomized stress harness for Lode.
Package chaos is a randomized stress harness for Lode.
errprefix
Package errprefix holds the test that enforces the error message prefix rule of CONTRACT_ERRORS.md: a source prefix such as "lode:" or "s3:" is added only where an error originates, never where a Lode error is wrapped.
Package errprefix holds the test that enforces the error message prefix rule of CONTRACT_ERRORS.md: a source prefix such as "lode:" or "s3:" is added only where an error originates, never where a Lode error is wrapped.
history
Package history is the snapshot-history core shared by Lode's containers.
Package history is the snapshot-history core shared by Lode's containers.
retry
Package retry holds the CAS-conflict retry schedule shared by Lode's containers: the configuration the WithRetry* options set, and the jittered exponential backoff a commit loop waits between attempts.
Package retry holds the CAS-conflict retry schedule shared by Lode's containers: the configuration the WithRetry* options set, and the jittered exponential backoff a commit loop waits between attempts.
storepath
Package storepath holds the rules every Store adapter applies to the keys and prefixes it is handed, so the fs, memory and S3 stores agree on what a valid object key is and what a listing prefix means (CONTRACT_STORAGE §Put, §List).
Package storepath holds the rules every Store adapter applies to the keys and prefixes it is handed, so the fs, memory and S3 stores agree on what a valid object key is and what a listing prefix means (CONTRACT_STORAGE §Put, §List).
testutil
Package testutil provides helpers for examples and tests.
Package testutil provides helpers for examples and tests.
validate
Package validate holds the argument and manifest validation errors every Lode package reports.
Package validate holds the argument and manifest validation errors every Lode package reports.
Package lode provides dataset snapshots, manifests, and metadata for object storage systems.
Package lode provides dataset snapshots, manifests, and metadata for object storage systems.
s3
Package s3 provides an S3-compatible storage adapter for Lode.
Package s3 provides an S3-compatible storage adapter for Lode.
volume
Package volume persists a sparse, fixed-length byte address space as immutable, cumulative snapshots.
Package volume persists a sparse, fixed-length byte address space as immutable, cumulative snapshots.

Jump to

Keyboard shortcuts

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