Examples
Examples and checks
Section titled “Examples and checks”The Effect entrypoint runs the same engine without the Promise wrapper:
import * as Effect from "effect/Effect";import { makeRuntime } from "@fungi.computer/watchdog/effect";
const runtime = await Effect.runPromise( makeRuntime({ owner, // the same owner as in the quick start executor: { execute: () => Effect.succeed({ kind: "completed" as const }) }, isAlive: () => Effect.succeed(true), wake: { recompute: () => Effect.void }, }),);const result = await Effect.runPromise(runtime.tick());Inside your own transaction, enqueue work with the domain write it belongs to:
owner.transactionSync(() => { owner.sql.exec("INSERT INTO orders (id) VALUES (?)", "order-1"); watchdog.transactional.enqueueAcceptedJob({ jobId: "charge-order-1", queue: "order-1", lane: "default", priority: 0, payload: { orderId: "order-1" }, state: "queued", });});The package tests run the engine on a real in-memory node:sqlite owner. They
cover the tick lifecycle, cancellation of queued and running jobs, disappearance
recovery, failure reasons, purge, queue projection, the transactional projection
and shared-storage leases. From the package directory:
pnpm test