Your first chain

Define a job type, start a chain with the client and let a worker process it, all in your browser.

A chain is Queuert's unit of work: your code creates it, a worker processes it, and you can wait for its result.

your codeclient.createChain
jobpendingsend-welcome-email
workerpending→running
jobcompletedclient.awaitChain

A job type names a kind of work and the shapes of its input and output. defineJobTypes declares them once, and both the client that starts chains and the worker that processes them read the same definitions, so a wrong input is a compile error. An entry type can start a chain.

Chains and jobs are rows in your own database. The lessons run on a real one inside your browser, PostgreSQL through PGlite or SQLite through sql.js; pick either above the editor. db.ts opens it, applies Queuert's migration and hands back the stateAdapter that the client and the worker read and write through, and the database's transaction that opens the transactions you pass to Queuert. It also exports a small sql helper the later lessons use for their own tables.

client.createChain inserts the chain's first job as pending. A worker runner picks it up, runs the type's attemptHandler and completes the job through applyJobOutcome with its output. client.awaitChain waits for the chain and returns that output.

The code below already defines send-welcome-email and starts a worker runner that processes it. Nothing happens yet, because no chain asks for the work.

Your task: create a send-welcome-email chain for user "ada" with client.createChain, wait for it with client.awaitChain, and log the chain's output.
esc

Search guides, integrations and every exported symbol.

↑ ↓ to navigate↵ to open