API Reference
workQueue()
Build a graph-visible work queue over a MessageBus subscription.
Import
import { workQueue } from "@graphrefly/ts/work-queue";
Signature
function workQueue(
graph: Graph,
opts: WorkQueueOptions<T>,
): WorkQueue<T>
Parameters
| Parameter | Type | Description |
|---|---|---|
graph | Graph | Graph that owns the queue nodes and command projections. |
opts | WorkQueueOptions<T> | Queue identity, source topic/subscription, bus, retry, lease, and clock options. |
Returns
A WorkQueue handle with graph nodes plus command helpers for submit, claim, complete, fail, cancel, schedule, and projections.
Example
import { graph } from "@graphrefly/ts/graph";
import { messageBus } from "@graphrefly/ts/messaging";
import { workQueue } from "@graphrefly/ts/work-queue";
const g = graph();
const bus = messageBus(g, { topics: ["jobs.submit"], name: "jobs" });
const queue = workQueue(g, {
queueId: "jobs",
topic: "jobs.submit",
subscriptionId: "workers",
bus,
});
queue.submit({ task: "index" });
Source
packages/ts/src/work-queue/index.ts