Expand description
PostgreSQL-backed Session implementation. Mirrors the sqlite backend’s
event-log shape; safe for concurrent writers via a per-session advisory lock.
Events are stored in a session_events table with a JSONB payload column.
Appends take a per-session pg_advisory_xact_lock before computing the next
sequence number, ensuring no two concurrent writers can produce the same
(session_id, sequence) pair.
§Pool setup
let pool = sqlx::PgPool::connect("postgres://user:pass@localhost/mydb").await?;§Recommended usage
let pool = sqlx::PgPool::connect("postgres://user:pass@localhost/mydb").await?;
// Migrate once at process start, then use open_without_migrate on the hot path.
PostgresSession::migrate(&pool).await?;
let session = PostgresSession::open_without_migrate(pool, "session-abc");
session.append(&[]).await?;Structs§
- Postgres
Session - PostgreSQL-backed
Session. One instance is one session (session_id); pools are shared across instances.