zerodds-durability-store-sqlite
Services — Durability. sqlite storage adapter in WAL mode, the default backend for
PERSISTENTdurability in the Durability-Service; implementsDurabilityStorefromzerodds-durability-store(ADR 0009).
- Source: crates/durability-store-sqlite
- API docs: docs.rs/zerodds-durability-store-sqlite
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
samplesholds 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
unregisteredrecords the time of unregistration per instance. set_contractis held in memory for the lifetime of the process.set_topic_metaalso writes type name, keyedness and contract to the tabletopic_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 beforetopic_metaexisted 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
zerodds-durability-service-bin(always compiled in).zerodds-durability-service, as a dev-dependency for its tests.
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 intests/load_10k.rs. The latter writes 10,000 instances with 3 samples each through aTieredStorewith a 512 KiB memory budget overSqliteStore.
zerodds-durability-store-sqlite
Dienste — Durability. sqlite-Speicheradapter im WAL-Modus, das Standard-Backend für Durability
PERSISTENTim Durability-Service; implementiertDurabilityStoreauszerodds-durability-store(ADR 0009).
- Quelle: crates/durability-store-sqlite
- API-Docs: docs.rs/zerodds-durability-store-sqlite
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
samplesenthä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
unregisteredhält den Zeitpunkt der Abmeldung pro Instanz fest. set_contractwird für die Lebensdauer des Prozesses im Speicher gehalten.set_topic_metaschreibt Typname, Key-Eigenschaft und Vertrag zusätzlich in die Tabelletopic_meta; ein neu gestarteter Daemon kann das Topic damit wieder bedienen, ohne es vorher zu registrieren.- Alle Tabellen werden mit
CREATE TABLE IF NOT EXISTSangelegt; eine Datenbank aus der Zeit vortopic_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
zerodds-durability-service-bin(immer einkompiliert).zerodds-durability-service, als Dev-Abhängigkeit für die Tests.
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 intests/load_10k.rs. Letztere schreibt 10.000 Instanzen mit je 3 Samples über einenTieredStoremit 512 KiB Speicherbudget in einenSqliteStore.