node
Import
Section titled “Import”import * as api from "@fungi.computer/shiitake/node";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | NodeRuntimeHost | The event-loop runtime host one Node process gives one durable Agent. |
| type alias | NodeStoreLease | An exclusive, process-held claim on one store file. |
| type alias | NodeShiitakeOptions | Everything a Node host supplies except the store and runtime it owns. |
| type alias | NodeShiitake | One durable Agent in a SQLite file, owned by this Node process. |
| function | nodeRuntimeHost() | The Node event loop as Shiitake’s runtime host: one reconciliation at a time,
re-run when woken during a pass, and a timer for the earliest due retry. It has
no queue policy; Watchdog owns execution and retries. observeFailure sees a
failed pass, which is retried after five seconds; if it throws, the throw is
logged and the retry still happens. |
| function | acquireNodeStoreLease() | Claim one store for this process: an exclusive transaction held open on a sidecar file, so a second owner of the same store is refused at once and the claim ends with the process, never with a missed heartbeat. |
| function | openNodeShiitake() | Open one durable Agent in a SQLite file on disk. The process holds an exclusive
lease on the store until close, so a second opener is refused. The store and
its lease file are private to this user (0600), and a store reached through a
symbolic link or with a second hard link is refused. Accepted work survives a
restart: reopening the file resumes it. |
NodeRuntimeHosttype alias
Section titled “NodeRuntimeHost”type NodeRuntimeHost = Readonly<{ runtime: RuntimeHost; scheduleWake: (at) => void; close: () => Promise<void>;}>;The event-loop runtime host one Node process gives one durable Agent.
NodeStoreLeasetype alias
Section titled “NodeStoreLease”type NodeStoreLease = Readonly<{ release: () => void;}>;An exclusive, process-held claim on one store file.
NodeShiitakeOptionstype alias
Section titled “NodeShiitakeOptions”type NodeShiitakeOptions = Omit<ShiitakeOptions, "store" | "runtime"> & Readonly<{ path: string; onRuntimeFailure?: (cause) => void; }>;Everything a Node host supplies except the store and runtime it owns.
NodeShiitaketype alias
Section titled “NodeShiitake”type NodeShiitake = Readonly<{ agent: ShiitakeOwnerAgent; routes: Hono<ShiitakeHttpEnv>; close: () => Promise<void>;}>;One durable Agent in a SQLite file, owned by this Node process.
nodeRuntimeHost()function
Section titled “nodeRuntimeHost()”function nodeRuntimeHost(observeFailure): NodeRuntimeHost;The Node event loop as Shiitake’s runtime host: one reconciliation at a time,
re-run when woken during a pass, and a timer for the earliest due retry. It has
no queue policy; Watchdog owns execution and retries. observeFailure sees a
failed pass, which is retried after five seconds; if it throws, the throw is
logged and the retry still happens.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
observeFailure |
(cause) => void |
Returns
Section titled “Returns”acquireNodeStoreLease()function
Section titled “acquireNodeStoreLease()”function acquireNodeStoreLease(sidecarPath): NodeStoreLease;Claim one store for this process: an exclusive transaction held open on a sidecar file, so a second owner of the same store is refused at once and the claim ends with the process, never with a missed heartbeat.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sidecarPath |
string |
Returns
Section titled “Returns”openNodeShiitake()function
Section titled “openNodeShiitake()”function openNodeShiitake(options): Promise< Readonly<{ agent: ShiitakeOwnerAgent; routes: Hono<ShiitakeHttpEnv>; close: () => Promise<void>; }>>;Open one durable Agent in a SQLite file on disk. The process holds an exclusive
lease on the store until close, so a second opener is refused. The store and
its lease file are private to this user (0600), and a store reached through a
symbolic link or with a second hard link is refused. Accepted work survives a
restart: reopening the file resumes it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
NodeShiitakeOptions |
Returns
Section titled “Returns”Promise<Readonly<{ agent:
ShiitakeOwnerAgent; routes:
Hono<ShiitakeHttpEnv>; close: () =>
Promise<void>; }>>