Skip to content
API reference

watchdog

Import
import * as api from "@fungi.computer/watchdog";
Kind Export Description
class WatchdogError Typed failures owned by the generic Watchdog engine.
type alias WatchdogExecutor Promise host executor for one generic running job.
type alias WatchdogOptions Options for constructing the Promise facade.
type alias WatchdogRuntime Promise facade over the canonical Effect runtime.
type alias ConcurrentWatchdogRuntime Promise runtime with the construction-time concurrent lane.
type alias WatchdogApi Factory for the Promise facade.
constant Watchdog Promise facade over the canonical Effect-owned runtime.

Typed failures owned by the generic Watchdog engine.

  • Error
Signature
new WatchdogError(failureKind, cause?): WatchdogError;
Parameter Type Description
failureKind | "store_unavailable" | "store_invalid" | "claim_unavailable" | "execution_failed" | "settlement_rejected" | "wake_unavailable" | "liveness_unavailable" -
cause? unknown The original thrown value, kept for server-side diagnosis only. cause is already the closed category above, so this is a separate field.

WatchdogError

Signature
Error.constructor;
Signature
readonly _tag: "WatchdogError";
Signature
readonly cause:
| "store_unavailable"
| "store_invalid"
| "claim_unavailable"
| "execution_failed"
| "settlement_rejected"
| "wake_unavailable"
| "liveness_unavailable";
Signature
Error.cause;
Signature
readonly optional underlying?: unknown;

WatchdogExecutortype alias

Section titled “WatchdogExecutor”
Signature
type WatchdogExecutor = (job, signal) => Promise<WatchdogExecutionDecision>;

Promise host executor for one generic running job.

Parameter Type
job WatchdogRunningJob
signal AbortSignal

Promise<WatchdogExecutionDecision>


WatchdogOptionstype alias

Section titled “WatchdogOptions”
Signature
type WatchdogOptions = Readonly<{
concurrentLane?: string;
owner: WatchdogSqliteOwner;
isAlive: (job) => Promise<boolean>;
execute: WatchdogExecutor;
wake: Readonly<{
recompute: () => Promise<void>;
}>;
project?: WatchdogQueueProjector;
}>;

Options for constructing the Promise facade.


WatchdogRuntimetype alias

Section titled “WatchdogRuntime”
Signature
type WatchdogRuntime = Readonly<{
hasPendingWork: () => Promise<boolean>;
ingest: (job) => Promise<WatchdogIngestResult>;
read: (jobId) => Promise<WatchdogReadResult>;
readQueueHead: (queue) => Promise<WatchdogQueueHead>;
tick: () => Promise<WatchdogTickResult>;
cancel: (input) => Promise<WatchdogCancellationResult>;
failLane: (input) => Promise<WatchdogLaneFailureResult>;
purge: (queue) => Promise<void>;
transactional: WatchdogTransactionalProjection;
}>;

Promise facade over the canonical Effect runtime.


ConcurrentWatchdogRuntimetype alias

Section titled “ConcurrentWatchdogRuntime”
Signature
type ConcurrentWatchdogRuntime = WatchdogRuntime &
Readonly<{
tickConcurrent: () => Promise<WatchdogTickResult>;
}>;

Promise runtime with the construction-time concurrent lane.


WatchdogApitype alias

Section titled “WatchdogApi”
Signature
type WatchdogApi = Readonly<{
make: {
(options): Promise<ConcurrentWatchdogRuntime>;
(options): Promise<
Readonly<{
hasPendingWork: () => Promise<boolean>;
ingest: (job) => Promise<WatchdogIngestResult>;
read: (jobId) => Promise<WatchdogReadResult>;
readQueueHead: (queue) => Promise<WatchdogQueueHead>;
tick: () => Promise<WatchdogTickResult>;
cancel: (input) => Promise<WatchdogCancellationResult>;
failLane: (input) => Promise<WatchdogLaneFailureResult>;
purge: (queue) => Promise<void>;
transactional: WatchdogTransactionalProjection;
}>
>;
};
}>;

Factory for the Promise facade.

Watchdogconstant

Section titled “Watchdog”
Signature
const Watchdog: WatchdogApi;

Promise facade over the canonical Effect-owned runtime.

Re-exports WatchdogCancellationIntentSchema


Re-exports WatchdogCancellationResultSchema


Re-exports WatchdogExecutionDecisionSchema


Re-exports WatchdogIngestResultSchema


Re-exports WatchdogQueuedJobSchema


Re-exports WatchdogQueueHeadSchema


Re-exports WatchdogReadResultSchema


Re-exports WatchdogRunningJobSchema


Re-exports WatchdogSettledJobSchema


Re-exports WatchdogStoredJobSchema


Re-exports EffectWatchdogOptions


Re-exports EffectWatchdogExecutor


Re-exports WatchdogCancellationDecision


Re-exports WatchdogCancellationIntent


Re-exports WatchdogCancellationResult


Re-exports WatchdogExecutionDecision


Re-exports WatchdogIngestResult


Re-exports WatchdogLivenessUnknown


Re-exports WatchdogLaneFailure


Re-exports WatchdogLaneFailureResult


Re-exports WatchdogQueuedJob


Re-exports WatchdogQueueHead


Re-exports WatchdogQueueProjector


Re-exports WatchdogQueueTransition


Re-exports WatchdogReadResult


Re-exports WatchdogRunningJob


Re-exports WatchdogRuntimeEffect


Re-exports ConcurrentWatchdogRuntimeEffect


Re-exports WatchdogSettledJob


Re-exports WatchdogSqliteCursor


Re-exports WatchdogSqliteOwner


Re-exports WatchdogSqliteValue


Re-exports WatchdogSqliteRow


Re-exports WatchdogStoredJob


Re-exports WatchdogTickResult


Re-exports WatchdogTransactionalProjection


Re-exports watchdogSqliteValueSchema


Re-exports watchdogSqliteRowSchema