zerodds-durability-store-sqlite

Services — Durability. sqlite storage adapter in WAL mode, the default backend for PERSISTENT durability in the Durability-Service; implements DurabilityStore from zerodds-durability-store (ADR 0009).

zerodds-durability-store-sqlite stores samples in an sqlite database. SqliteStore::open(path, default_contract) opens a database file, SqliteStore::open_in_memory(default_contract) an in-memory database. The connection runs with PRAGMA journal_mode=WAL; synchronous=NORMAL; the crate docs describe this as ACID and crash-safe without an fsync per insert.

  • Table samples holds one row per sample (topic, instance, sequence number, creation time, payload, representation, byte order, GUID and sequence number of the source writer). The primary key (topic, instance, sequence) makes a re-send idempotent.
  • Table unregistered records the time of unregistration per instance.
  • set_contract is held in memory for the lifetime of the process. set_topic_meta also writes type name, keyedness and contract to the table topic_meta, so a restarted daemon can serve the topic again without registering it first.
  • All tables are created with CREATE TABLE IF NOT EXISTS; a database from before topic_meta existed opens unchanged.
  • The schema is documented in the crate source; the database file can be read with any SQL tool.

sqlite comes from the workspace dependency rusqlite 0.32 with the feature bundled, so the sqlite library is compiled into the build.

Consumers

Status

  • std, #![forbid(unsafe_code)]. Safety classification in the crate docs: STANDARD.
  • Library only, no binary, no cargo features.
  • Test functions in the source: 11 in tests/sqlite_store.rs, 1 in tests/load_10k.rs. The latter writes 10,000 instances with 3 samples each through a TieredStore with a 512 KiB memory budget over SqliteStore.

zerodds-durability-store-sqlite

Dienste — Durability. sqlite-Speicheradapter im WAL-Modus, das Standard-Backend für Durability PERSISTENT im Durability-Service; implementiert DurabilityStore aus zerodds-durability-store (ADR 0009).

zerodds-durability-store-sqlite legt Samples in einer sqlite-Datenbank ab. SqliteStore::open(path, default_contract) öffnet eine Datenbankdatei, SqliteStore::open_in_memory(default_contract) eine Datenbank im Speicher. Die Verbindung läuft mit PRAGMA journal_mode=WAL; synchronous=NORMAL; die Crate-Dokumentation beschreibt das als ACID und absturzsicher ohne fsync pro Einfügung.

  • Die Tabelle samples enthält eine Zeile pro Sample (Topic, Instanz, Sequenznummer, Erzeugungszeit, Nutzdaten, Repräsentation, Byte-Reihenfolge, GUID und Sequenznummer des Quell-Writers). Der Primärschlüssel (topic, instance, sequence) macht ein erneutes Senden idempotent.
  • Die Tabelle unregistered hält den Zeitpunkt der Abmeldung pro Instanz fest.
  • set_contract wird für die Lebensdauer des Prozesses im Speicher gehalten. set_topic_meta schreibt Typname, Key-Eigenschaft und Vertrag zusätzlich in die Tabelle topic_meta; ein neu gestarteter Daemon kann das Topic damit wieder bedienen, ohne es vorher zu registrieren.
  • Alle Tabellen werden mit CREATE TABLE IF NOT EXISTS angelegt; eine Datenbank aus der Zeit vor topic_meta öffnet sich unverändert.
  • Das Schema ist im Quelltext der Crate dokumentiert; die Datenbankdatei lässt sich mit jedem SQL-Werkzeug lesen.

sqlite kommt aus der Workspace-Abhängigkeit rusqlite 0.32 mit dem Feature bundled; die sqlite-Bibliothek wird also mitkompiliert.

Konsumenten

Status

  • std, #![forbid(unsafe_code)]. Einstufung in der Crate-Dokumentation (safety classification): STANDARD.
  • Nur Bibliothek, kein Binary, keine Cargo-Features.
  • Testfunktionen im Quelltext: 11 in tests/sqlite_store.rs, 1 in tests/load_10k.rs. Letztere schreibt 10.000 Instanzen mit je 3 Samples über einen TieredStore mit 512 KiB Speicherbudget in einen SqliteStore.