-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueueflow.ts
More file actions
33 lines (30 loc) · 1.08 KB
/
queueflow.ts
File metadata and controls
33 lines (30 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* A single, shared QueueFlow client built from the environment.
*
* In a real app you'd construct this once at startup and inject it; here we
* export a module singleton for brevity.
*/
import { QueueFlow } from "@queueflow/sdk";
export const qf = new QueueFlow({
baseUrl: process.env.QUEUEFLOW_URL ?? "http://localhost:8000",
token: process.env.QUEUEFLOW_TOKEN ?? "dev",
// Modest per-request timeout; the SDK retries idempotent calls on 5xx/network.
timeoutMs: 10_000,
});
/**
* Map the *business* tasks this app cares about onto the task handlers that the
* stock QueueFlow dev server actually registers (`echo`, `log`, `sleep`,
* `fail`).
*
* In production you would register real handlers in the Rust worker
* (`Engine::builder(...).register("send_welcome_email", ...)`) and use those
* names directly. Mapping them here keeps the example runnable against an
* unmodified server while still demonstrating the end-to-end flow.
*/
export const TASKS = {
sendWelcomeEmail: "echo",
generateReport: "sleep",
extract: "echo",
transform: "echo",
load: "echo",
} as const;