Examples
Postgres Persistence
Postgres persistence keeps loop state durable across restarts while preserving runtime behavior and actor/guard semantics.
Store swap
1"cmt">// before2const system = await createLoopSystem({ loops: [definition], store: memoryStore() })3 4"cmt">// after5const pool = new Pool({ connectionString: process.env.DATABASE_URL })6await createSchema(pool)7const system = await createLoopSystem({ loops: [definition], store: postgresStore(pool) })Loop definitions and transition calls stay unchanged.
Schema bootstrap
1import { createSchema } from "@loop-engine/adapter-postgres"2import { Pool } from "pg"3 4const pool = new Pool({ connectionString: process.env.DATABASE_URL })5await createSchema(pool)Runtime status
Environment
DATABASE_URLpoints to PostgreSQL.- Use connection pooling for service workloads.
- Configure SSL and timeout limits in production.
Full source
- https://github.com/loopengine/loop-examples/tree/main/postgres-persistence