@paraharness/postgres
Distributed PostgreSQL runtime drivers and declarative postgres.* builders for Paraharness. This package provides transactional multi-worker persistence for LedgerStore, Copy-on-Write TopologyStore, LessonStore, and relational global rules sources over PostgreSQL connection pools.
Installation
With npm:
bash
npm install @paraharness/postgres @paraharness/core zodWith yarn:
bash
yarn add @paraharness/postgres @paraharness/core zodWith pnpm:
bash
pnpm add @paraharness/postgres @paraharness/core zodUsage
ts
import { P, z } from '@paraharness/core';
import { createExecutorRegistry } from '@paraharness/core/runtime';
import { postgres, postgresExecutors } from '@paraharness/postgres';
const TaskInput = z.object({
id: z.string(),
prompt: z.string(),
});
const dbUrl = P.env('DATABASE_URL');
const ledger = postgres
.ledger(dbUrl)
.compactWhen(($c) =>
$c
.onTerminalExit(['done', 'cancelled'], { afterGracePeriodHours: 48 })
.retainFailedRunsForDays(30),
);
const repoTopology = P.topology('repo-topology')
.store(postgres.topologyStore(dbUrl))
.partitions({
db: {},
api: { dependsOn: ['db'] },
});
const repoLessons = P.lessons('repo-lessons')
.store(postgres.lessonStore(dbUrl))
.queryFrom(TaskInput, (item) => item.prompt);
const registry = createExecutorRegistry(postgresExecutors);Documentation
See the @paraharness/postgres API Reference for full type and builder specifications.
License
MIT © Tornike Tsomaia