Skip to main content

Crate entelix_graphmemory_pg

Crate entelix_graphmemory_pg 

Source
Expand description

§entelix-graphmemory-pg

Concrete entelix_memory::GraphMemory implementation backed by Postgres (no extension required) — typed nodes + typed, timestamped edges keyed by entelix_memory::Namespace.

Companion to the trait-only entelix_memory crate: sqlx specifics live here so users who plug their own GraphMemory pay nothing in compile time.

§One-call setup

use entelix_graphmemory_pg::PgGraphMemory;

let graph = PgGraphMemory::<String, String>::builder()
    .with_connection_string("postgres://localhost/entelix")
    .build()
    .await?;

§Multi-tenancy

Two-table design (graph_nodes + graph_edges) with composite (namespace_key, id) primary keys. Every read / write rides a WHERE namespace_key = $1 anchor — invariant 11 / F2 demand structural tenant isolation, and the composite PK doubles as the B-tree index that anchor relies on.

Defense-in-depth via Postgres row-level security (analogous to ’s treatment of the entelix-persistence tables) is reserved for a follow-up slice — operators that need it today enable it externally with a policy that consults current_setting('entelix.tenant_id', true) against the tenant_id segment encoded in namespace_key.

§Schema-as-code escape hatch

Operators that own the schema externally (DBA-managed, IaC, migration pipeline) call PgGraphMemoryBuilder::with_auto_migrate with false — the builder skips table / index creation, trusting the operator to have stamped them.

Structs§

PgGraphMemory
Postgres-backed GraphMemory<N, E>.
PgGraphMemoryBuilder
Fluent builder for PgGraphMemory. Use PgGraphMemory::builder.

Enums§

PgGraphMemoryError
Errors that can surface from PgGraphMemory.

Type Aliases§

PgGraphMemoryResult
Result alias used inside entelix-graphmemory-pg.