Skip to main content

Module pg_loro_store

Module pg_loro_store 

Source
Expand description

Postgres-backed CRDT snapshot store.

Mirrors loro_store::LoroStore (the SQLite path) but persists the per-row Loro snapshots into a PG _pylon_crdt_snapshots table instead of a SQLite sidecar. Cache shape, hydrate-on-miss, and locking model are identical so the CRDT semantics don’t drift between backends.

Every method is generic over PgConn, which is implemented for both postgres::Client and postgres::Transaction. That’s what lets the runtime call apply_patch inside the same transaction that writes the materialized entity row + maintains the FTS shadow — sidecar write, entity write, and FTS write either all commit or all roll back, so a crash mid-write can’t desync the CRDT snapshot from the materialized columns.

Structs§

PgCrdtHookImpl
Bridge struct that lets PgTxStore (in pylon-storage) call back into the runtime’s CRDT machinery without a direct dependency. Lives only for the duration of a single mutation tx.
PgLoroStore
PG analogue of LoroStore. Lives on the Postgres-backed runtime; holds the per-row LoroDoc cache (mutated only behind the inner per-row Mutex) and persists snapshots to the PG sidecar table.

Constants§

CREATE_PG_SIDECAR_SQL
SQL to create the PG sidecar table. Idempotent — called every time the runtime opens a Postgres backend so a fresh database gets the table without a manual migration step.

Functions§

ensure_sidecar