Skip to main content

Crate mempill_postgres

Crate mempill_postgres 

Source
Expand description

§mempill-postgres

PostgreSQL-backed PersistencePort adapter for mempill.

§Usage

use mempill_postgres::{open_postgres, PostgresEngine};
use mempill_core::{EngineConfig, NoOpOracle, NoOpVector};
use std::sync::Arc;

let conn_str = "host=localhost port=5432 user=mempill dbname=mempill password=secret";
let engine: PostgresEngine<NoOpOracle, NoOpVector> = open_postgres(conn_str, None, None, EngineConfig::default())?;

§Topology-b vs topology-a

One backend per deployment: downstream consumers depend on EITHER mempill-sqlite OR mempill-postgres, never both.

§Concurrency model

  • r2d2 pool (max 20 connections) enables concurrent cross-agent transactions.
  • pg_advisory_xact_lock(hashtext(agent_id)::bigint) serializes same-agent writes at the DB level.
  • UNIQUE(agent_id, stream_seq) on ledger_entries provides OCC belt-and-suspenders against duplicate sequence numbers.
  • requires_global_write_serialization() returns false — EngineHandle skips the global write lock, enabling true Postgres concurrency across agents.

Modules§

migrations

Structs§

PostgresPendingStore
PostgreSQL-backed PendingAdjudicationPort implementation.
PostgresPersistenceStore
The PostgreSQL-backed PersistencePort implementation.
PostgresTxn
An open, uncommitted Postgres transaction scoped to one agent_id.

Enums§

PostgresStoreError
Error type for PostgresPersistenceStore operations.

Functions§

open_postgres
Convenience constructor: build a PostgresEngine<O, V> (an EngineHandle backed by PostgresPersistenceStore) from a connection string.
open_postgres_with_oracle
Convenience constructor: build a PostgresEngine<O, V> wired with a real oracle and the Postgres-backed pending-adjudication store.

Type Aliases§

PostgresEngine
Type alias for an EngineHandle backed by PostgresPersistenceStore.