Documentation
¶
Overview ¶
Package sqlite is the meta scale engine: one WAL database, namespace = table group, generic (id, data) rows per root-declared table (§2-§4, v2.28).
Index ¶
- Constants
- func Backup(ctx context.Context, dbPath, destPath string) error
- func Checkpoint(ctx context.Context, dbPath string) error
- func Init(ctx context.Context, dbPath string, namespaces ...Namespace) error
- func InitForRecovery(ctx context.Context, dbPath string, namespaces ...Namespace) error
- func InitForRecoveryIfNeeded(ctx context.Context, dbPath string, namespaces ...Namespace) error
- func InitIfMissing(ctx context.Context, dbPath string, namespaces ...Namespace) error
- func MarkConverted(ctx context.Context, dbPath, ns, source, sha256 string, records int) error
- func RefuseManifest(dbPath string) error
- type Namespace
- type Store
Constants ¶
const ( // ApplicationID marks a cocoon DB ("COCN"); UserVersion is the schema // generation — verified on every open, written only at init (§6). ApplicationID = 0x434F434E UserVersion = 1 // DBFileName is the single database under the meta root; ManifestName // beside it marks an in-flight conversion, which ordinary opens refuse (§6). DBFileName = "meta.db" ManifestName = "meta-convert.manifest" )
Variables ¶
This section is empty.
Functions ¶
func Backup ¶
Backup replaces destPath with a consistent single-file copy: VACUUM INTO a temp file, integrity-check, fsync, atomic rename, parent-dir sync (§4). A previously published backup stays intact until the rename commits (§9).
func Checkpoint ¶
Checkpoint folds the WAL back into the main file (TRUNCATE) so the database is a single self-contained file (§6 aside rule).
func Init ¶
Init creates a fresh store: schema DDL, identity pragmas and one initialized meta_state row per namespace, all in ONE transaction — a crash mid-init leaves nothing or a complete store (§6). An empty database is a failed init and is restarted; anything else is left for the operator.
func InitForRecovery ¶
InitForRecovery is Init without the manifest guard — the conversion tool creates its target while the manifest is necessarily present (§6).
func InitForRecoveryIfNeeded ¶ added in v0.5.6
InitForRecoveryIfNeeded creates or repairs the conversion target, passing a completed one through.
func InitIfMissing ¶ added in v0.5.6
InitIfMissing bootstraps a fresh store or repairs a crashed one, serializing racing processes behind a transient flock.
func MarkConverted ¶
MarkConverted records a namespace's conversion provenance in meta_state (§6).
func RefuseManifest ¶
RefuseManifest fails when a conversion manifest sits beside dbPath, meaning an offline conversion is unfinished.
Types ¶
type Namespace ¶
Namespace declares one namespace's table set; Tables lists the record tables (satellites included) the SPI may address.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the sqlite engine: writerDurable/writerRelaxed single-conn handles, a bounded reader pool, and a pinned notifier connection (§4). Statements are prepared per handle at Open — the table set is static.
func Open ¶
Open verifies identity, version and per-namespace meta_state, then builds the connection set. It never creates or migrates — that is Init's job.
func OpenForRecovery ¶
OpenForRecovery is Open without the manifest guard, for the conversion tool itself (§6) — never for ordinary callers.
func (*Store) Events ¶
Events subscribes to committed-change signals: fsnotify on the DB's parent dir confirmed via data_version on a pinned connection — the counter is only comparable across calls on ONE connection and never moves for that connection's own commits (§7).