@exulu/backend 1.48.2 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +351 -42
- package/dist/index.d.cts +96 -1
- package/dist/index.d.ts +96 -1
- package/dist/index.js +340 -38
- package/ee/{markdown.ts → chunking/markdown.ts} +2 -2
- package/ee/python/README.md +295 -0
- package/ee/python/documents/processing/README.md +155 -0
- package/ee/{documents → python/documents}/processing/doc_processor.ts +25 -17
- package/ee/{documents/processing/pdf_to_markdown.py → python/documents/processing/document_to_markdown.py} +3 -10
- package/ee/python/setup.sh +180 -0
- package/package.json +14 -3
- package/scripts/postinstall.cjs +149 -0
- package/.agents/skills/mintlify/SKILL.md +0 -347
- package/.editorconfig +0 -15
- package/.eslintrc.json +0 -52
- package/.github/workflows/release-backend.yml +0 -38
- package/.husky/commit-msg +0 -1
- package/.jscpd.json +0 -18
- package/.mcp.json +0 -25
- package/.nvmrc +0 -1
- package/.prettierignore +0 -5
- package/.prettierrc.json +0 -12
- package/CHANGELOG.md +0 -8
- package/SECURITY.md +0 -5
- package/commitlint.config.js +0 -4
- package/devops/documentation/patch-older-releases.md +0 -42
- package/ee/documents/processing/build_pdf_processor.sh +0 -35
- package/ee/documents/processing/chunk_markdown.py +0 -263
- package/ee/documents/processing/pdf_processor.spec +0 -115
- package/eslint.config.js +0 -88
- package/jest.config.ts +0 -25
- package/mintlify-docs/.mintignore +0 -7
- package/mintlify-docs/AGENTS.md +0 -33
- package/mintlify-docs/CLAUDE.MD +0 -50
- package/mintlify-docs/CONTRIBUTING.md +0 -32
- package/mintlify-docs/LICENSE +0 -21
- package/mintlify-docs/README.md +0 -55
- package/mintlify-docs/ai-tools/claude-code.mdx +0 -43
- package/mintlify-docs/ai-tools/cursor.mdx +0 -39
- package/mintlify-docs/ai-tools/windsurf.mdx +0 -39
- package/mintlify-docs/api-reference/core-types/agent-types.mdx +0 -110
- package/mintlify-docs/api-reference/core-types/analytics-types.mdx +0 -95
- package/mintlify-docs/api-reference/core-types/configuration-types.mdx +0 -83
- package/mintlify-docs/api-reference/core-types/evaluation-types.mdx +0 -106
- package/mintlify-docs/api-reference/core-types/job-types.mdx +0 -135
- package/mintlify-docs/api-reference/core-types/overview.mdx +0 -73
- package/mintlify-docs/api-reference/core-types/prompt-types.mdx +0 -102
- package/mintlify-docs/api-reference/core-types/rbac-types.mdx +0 -163
- package/mintlify-docs/api-reference/core-types/session-types.mdx +0 -77
- package/mintlify-docs/api-reference/core-types/user-management.mdx +0 -112
- package/mintlify-docs/api-reference/core-types/workflow-types.mdx +0 -88
- package/mintlify-docs/api-reference/core-types.mdx +0 -585
- package/mintlify-docs/api-reference/dynamic-types.mdx +0 -851
- package/mintlify-docs/api-reference/endpoint/create.mdx +0 -4
- package/mintlify-docs/api-reference/endpoint/delete.mdx +0 -4
- package/mintlify-docs/api-reference/endpoint/get.mdx +0 -4
- package/mintlify-docs/api-reference/endpoint/webhook.mdx +0 -4
- package/mintlify-docs/api-reference/introduction.mdx +0 -661
- package/mintlify-docs/api-reference/mutations.mdx +0 -1012
- package/mintlify-docs/api-reference/openapi.json +0 -217
- package/mintlify-docs/api-reference/queries.mdx +0 -1154
- package/mintlify-docs/backend/introduction.mdx +0 -218
- package/mintlify-docs/changelog.mdx +0 -387
- package/mintlify-docs/community-edition.mdx +0 -304
- package/mintlify-docs/core/exulu-agent/api-reference.mdx +0 -894
- package/mintlify-docs/core/exulu-agent/configuration.mdx +0 -690
- package/mintlify-docs/core/exulu-agent/introduction.mdx +0 -552
- package/mintlify-docs/core/exulu-app/api-reference.mdx +0 -481
- package/mintlify-docs/core/exulu-app/configuration.mdx +0 -319
- package/mintlify-docs/core/exulu-app/introduction.mdx +0 -117
- package/mintlify-docs/core/exulu-authentication.mdx +0 -810
- package/mintlify-docs/core/exulu-chunkers/api-reference.mdx +0 -1011
- package/mintlify-docs/core/exulu-chunkers/configuration.mdx +0 -596
- package/mintlify-docs/core/exulu-chunkers/introduction.mdx +0 -403
- package/mintlify-docs/core/exulu-context/api-reference.mdx +0 -911
- package/mintlify-docs/core/exulu-context/configuration.mdx +0 -648
- package/mintlify-docs/core/exulu-context/introduction.mdx +0 -394
- package/mintlify-docs/core/exulu-database.mdx +0 -811
- package/mintlify-docs/core/exulu-default-agents.mdx +0 -545
- package/mintlify-docs/core/exulu-eval/api-reference.mdx +0 -772
- package/mintlify-docs/core/exulu-eval/configuration.mdx +0 -680
- package/mintlify-docs/core/exulu-eval/introduction.mdx +0 -459
- package/mintlify-docs/core/exulu-logging.mdx +0 -464
- package/mintlify-docs/core/exulu-otel.mdx +0 -670
- package/mintlify-docs/core/exulu-queues/api-reference.mdx +0 -648
- package/mintlify-docs/core/exulu-queues/configuration.mdx +0 -650
- package/mintlify-docs/core/exulu-queues/introduction.mdx +0 -474
- package/mintlify-docs/core/exulu-reranker/api-reference.mdx +0 -630
- package/mintlify-docs/core/exulu-reranker/configuration.mdx +0 -663
- package/mintlify-docs/core/exulu-reranker/introduction.mdx +0 -516
- package/mintlify-docs/core/exulu-tool/api-reference.mdx +0 -723
- package/mintlify-docs/core/exulu-tool/configuration.mdx +0 -805
- package/mintlify-docs/core/exulu-tool/introduction.mdx +0 -539
- package/mintlify-docs/core/exulu-variables/api-reference.mdx +0 -699
- package/mintlify-docs/core/exulu-variables/configuration.mdx +0 -736
- package/mintlify-docs/core/exulu-variables/introduction.mdx +0 -511
- package/mintlify-docs/development.mdx +0 -94
- package/mintlify-docs/docs.json +0 -248
- package/mintlify-docs/enterprise-edition.mdx +0 -538
- package/mintlify-docs/essentials/code.mdx +0 -35
- package/mintlify-docs/essentials/images.mdx +0 -59
- package/mintlify-docs/essentials/markdown.mdx +0 -88
- package/mintlify-docs/essentials/navigation.mdx +0 -87
- package/mintlify-docs/essentials/reusable-snippets.mdx +0 -110
- package/mintlify-docs/essentials/settings.mdx +0 -318
- package/mintlify-docs/favicon.svg +0 -3
- package/mintlify-docs/frontend/introduction.mdx +0 -39
- package/mintlify-docs/getting-started.mdx +0 -267
- package/mintlify-docs/guides/custom-agent.mdx +0 -608
- package/mintlify-docs/guides/first-agent.mdx +0 -315
- package/mintlify-docs/images/admin_ui.png +0 -0
- package/mintlify-docs/images/contexts.png +0 -0
- package/mintlify-docs/images/create_agents.png +0 -0
- package/mintlify-docs/images/evals.png +0 -0
- package/mintlify-docs/images/graphql.png +0 -0
- package/mintlify-docs/images/graphql_api.png +0 -0
- package/mintlify-docs/images/hero-dark.png +0 -0
- package/mintlify-docs/images/hero-light.png +0 -0
- package/mintlify-docs/images/hero.png +0 -0
- package/mintlify-docs/images/knowledge_sources.png +0 -0
- package/mintlify-docs/images/mcp.png +0 -0
- package/mintlify-docs/images/scaling.png +0 -0
- package/mintlify-docs/index.mdx +0 -411
- package/mintlify-docs/logo/dark.svg +0 -9
- package/mintlify-docs/logo/light.svg +0 -9
- package/mintlify-docs/partners.mdx +0 -558
- package/mintlify-docs/products.mdx +0 -77
- package/mintlify-docs/snippets/snippet-intro.mdx +0 -4
- package/mintlify-docs/styles.css +0 -207
- package/ngrok.bash +0 -1
- package/ngrok.md +0 -6
- package/ngrok.yml +0 -10
- package/release.config.cjs +0 -15
- package/skills-lock.json +0 -10
- package/types/context-processor.ts +0 -45
- package/types/enums/eval-types.ts +0 -5
- package/types/enums/field-types.ts +0 -1
- package/types/enums/jobs.ts +0 -11
- package/types/enums/statistics.ts +0 -13
- package/types/exulu-table-definition.ts +0 -79
- package/types/file-types.ts +0 -18
- package/types/models/agent-session.ts +0 -27
- package/types/models/agent.ts +0 -68
- package/types/models/context.ts +0 -53
- package/types/models/embedding.ts +0 -17
- package/types/models/eval-run.ts +0 -40
- package/types/models/exulu-agent-tool-config.ts +0 -11
- package/types/models/item.ts +0 -21
- package/types/models/job.ts +0 -8
- package/types/models/project.ts +0 -16
- package/types/models/rate-limiter-rules.ts +0 -7
- package/types/models/test-case.ts +0 -25
- package/types/models/tool.ts +0 -9
- package/types/models/user-role.ts +0 -12
- package/types/models/user.ts +0 -20
- package/types/models/variable.ts +0 -8
- package/types/models/vector-methods.ts +0 -7
- package/types/provider-config.ts +0 -21
- package/types/queue-config.ts +0 -16
- package/types/rbac-rights-modes.ts +0 -1
- package/types/statistics.ts +0 -20
- package/types/workflow.ts +0 -31
- /package/ee/{documents → python/documents}/THIRD_PARTY_LICENSES/docling.txt +0 -0
- /package/ee/{documents/processing → python}/requirements.txt +0 -0
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Overview"
|
|
3
|
-
description: "Background job processing with BullMQ for asynchronous task execution"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## Overview
|
|
7
|
-
|
|
8
|
-
`ExuluQueues` manages background job queues using BullMQ and Redis. It enables asynchronous processing of long-running tasks like embeddings generation, document processing, scheduled data syncs, and agent workflows. Queues help keep your application responsive by offloading heavy work to background workers.
|
|
9
|
-
|
|
10
|
-
## Key features
|
|
11
|
-
|
|
12
|
-
<CardGroup cols={2}>
|
|
13
|
-
<Card title="BullMQ integration" icon="bolt">
|
|
14
|
-
Built on BullMQ, a robust Redis-based queue system
|
|
15
|
-
</Card>
|
|
16
|
-
<Card title="Concurrency control" icon="gauge">
|
|
17
|
-
Configure worker and queue-level concurrency limits
|
|
18
|
-
</Card>
|
|
19
|
-
<Card title="Rate limiting" icon="clock">
|
|
20
|
-
Control job processing rate to manage API limits
|
|
21
|
-
</Card>
|
|
22
|
-
<Card title="Retries & backoff" icon="rotate">
|
|
23
|
-
Automatic retry with exponential or linear backoff
|
|
24
|
-
</Card>
|
|
25
|
-
<Card title="Timeouts" icon="hourglass">
|
|
26
|
-
Set maximum execution time for jobs
|
|
27
|
-
</Card>
|
|
28
|
-
<Card title="Telemetry" icon="chart-line">
|
|
29
|
-
OpenTelemetry integration for monitoring
|
|
30
|
-
</Card>
|
|
31
|
-
</CardGroup>
|
|
32
|
-
|
|
33
|
-
## What is a queue?
|
|
34
|
-
|
|
35
|
-
A queue is a system for managing background jobs:
|
|
36
|
-
|
|
37
|
-
1. **Jobs are added** to the queue with data and options
|
|
38
|
-
2. **Workers process jobs** asynchronously in the background
|
|
39
|
-
3. **Results are tracked** with success/failure status
|
|
40
|
-
4. **Failed jobs retry** automatically based on configuration
|
|
41
|
-
|
|
42
|
-
Queues prevent blocking operations from slowing down your application and enable horizontal scaling by adding more workers.
|
|
43
|
-
|
|
44
|
-
## Why use queues?
|
|
45
|
-
|
|
46
|
-
<AccordionGroup>
|
|
47
|
-
<Accordion title="Long-running operations">
|
|
48
|
-
Tasks like embeddings generation, document processing, or data exports can take seconds or minutes. Queues let you return immediately to users while work continues in the background.
|
|
49
|
-
</Accordion>
|
|
50
|
-
|
|
51
|
-
<Accordion title="Rate limit management">
|
|
52
|
-
External APIs often have rate limits. Queues control processing speed to stay within limits while maximizing throughput.
|
|
53
|
-
</Accordion>
|
|
54
|
-
|
|
55
|
-
<Accordion title="Reliability">
|
|
56
|
-
Jobs persist in Redis. If a worker crashes, jobs aren't lost and will retry when workers restart.
|
|
57
|
-
</Accordion>
|
|
58
|
-
|
|
59
|
-
<Accordion title="Scalability">
|
|
60
|
-
Add more worker processes to handle increased load without changing code.
|
|
61
|
-
</Accordion>
|
|
62
|
-
|
|
63
|
-
<Accordion title="Scheduled execution">
|
|
64
|
-
Process jobs at specific times or intervals (e.g., daily data syncs, weekly reports).
|
|
65
|
-
</Accordion>
|
|
66
|
-
</AccordionGroup>
|
|
67
|
-
|
|
68
|
-
## Quick start
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { ExuluQueues } from "@exulu/backend";
|
|
72
|
-
|
|
73
|
-
// Register a queue
|
|
74
|
-
const embeddingsQueue = ExuluQueues.register(
|
|
75
|
-
"embeddings", // Queue name
|
|
76
|
-
{
|
|
77
|
-
worker: 5, // 5 concurrent jobs per worker
|
|
78
|
-
queue: 10 // 10 global concurrent jobs
|
|
79
|
-
},
|
|
80
|
-
10, // Rate limit: 10 jobs/second
|
|
81
|
-
180 // Timeout: 180 seconds
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
// Use the queue
|
|
85
|
-
const queueConfig = await embeddingsQueue.use();
|
|
86
|
-
|
|
87
|
-
// Add a job to the queue
|
|
88
|
-
await queueConfig.queue.add("generate-embeddings", {
|
|
89
|
-
contextId: "docs",
|
|
90
|
-
itemId: "item-123"
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Create a worker to process jobs
|
|
94
|
-
import { Worker } from "bullmq";
|
|
95
|
-
|
|
96
|
-
const worker = new Worker(
|
|
97
|
-
"embeddings",
|
|
98
|
-
async (job) => {
|
|
99
|
-
console.log("Processing:", job.data);
|
|
100
|
-
|
|
101
|
-
// Do the work
|
|
102
|
-
await generateEmbeddings(job.data.contextId, job.data.itemId);
|
|
103
|
-
|
|
104
|
-
return { success: true };
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
connection: redisServer,
|
|
108
|
-
concurrency: queueConfig.concurrency.worker,
|
|
109
|
-
limiter: {
|
|
110
|
-
max: queueConfig.ratelimit,
|
|
111
|
-
duration: 1000
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Architecture
|
|
118
|
-
|
|
119
|
-
### BullMQ and Redis
|
|
120
|
-
|
|
121
|
-
ExuluQueues wraps BullMQ, which uses Redis for:
|
|
122
|
-
|
|
123
|
-
- **Job storage** - Jobs persist in Redis
|
|
124
|
-
- **State management** - Track job status (waiting, active, completed, failed)
|
|
125
|
-
- **Locks** - Prevent duplicate processing
|
|
126
|
-
- **Pub/Sub** - Notify workers of new jobs
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
import { Queue } from "bullmq";
|
|
130
|
-
|
|
131
|
-
// ExuluQueues creates BullMQ Queue instances
|
|
132
|
-
const queue = new Queue("my-queue", {
|
|
133
|
-
connection: {
|
|
134
|
-
host: "localhost",
|
|
135
|
-
port: 6379
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Concurrency levels
|
|
141
|
-
|
|
142
|
-
ExuluQueues supports two concurrency levels:
|
|
143
|
-
|
|
144
|
-
<Tabs>
|
|
145
|
-
<Tab title="Worker concurrency">
|
|
146
|
-
Number of jobs a single worker process handles simultaneously:
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
concurrency: {
|
|
150
|
-
worker: 5 // Each worker processes 5 jobs at once
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Higher values = more throughput per worker, but more memory/CPU usage.
|
|
155
|
-
</Tab>
|
|
156
|
-
|
|
157
|
-
<Tab title="Queue concurrency">
|
|
158
|
-
Maximum jobs processing across all workers globally:
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
concurrency: {
|
|
162
|
-
queue: 10 // Max 10 jobs processing across all workers
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Prevents overwhelming external services or databases.
|
|
167
|
-
</Tab>
|
|
168
|
-
</Tabs>
|
|
169
|
-
|
|
170
|
-
**Example scenario:**
|
|
171
|
-
- Queue concurrency: 20
|
|
172
|
-
- Worker concurrency: 5
|
|
173
|
-
- 10 workers running
|
|
174
|
-
|
|
175
|
-
Each worker can handle 5 jobs, but only 20 jobs will run simultaneously across all workers.
|
|
176
|
-
|
|
177
|
-
### Rate limiting
|
|
178
|
-
|
|
179
|
-
Control job processing speed:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
ExuluQueues.register(
|
|
183
|
-
"api-calls",
|
|
184
|
-
{ worker: 1, queue: 5 },
|
|
185
|
-
10 // Process max 10 jobs per second
|
|
186
|
-
);
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Useful for:
|
|
190
|
-
- Staying within API rate limits
|
|
191
|
-
- Preventing database overload
|
|
192
|
-
- Controlling costs (API calls, LLM tokens)
|
|
193
|
-
|
|
194
|
-
## Common use cases
|
|
195
|
-
|
|
196
|
-
<Tabs>
|
|
197
|
-
<Tab title="Embeddings generation">
|
|
198
|
-
```typescript
|
|
199
|
-
const embeddingsQueue = ExuluQueues.register(
|
|
200
|
-
"embeddings",
|
|
201
|
-
{ worker: 5, queue: 10 },
|
|
202
|
-
10, // 10 jobs/sec
|
|
203
|
-
300 // 5 min timeout
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
// Used by ExuluContext
|
|
207
|
-
const context = new ExuluContext({
|
|
208
|
-
id: "docs",
|
|
209
|
-
embedder: new ExuluEmbedder({
|
|
210
|
-
// ...
|
|
211
|
-
queue: await embeddingsQueue.use()
|
|
212
|
-
})
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// Jobs are queued automatically
|
|
216
|
-
await context.createItem(item, config);
|
|
217
|
-
```
|
|
218
|
-
</Tab>
|
|
219
|
-
|
|
220
|
-
<Tab title="Document processing">
|
|
221
|
-
```typescript
|
|
222
|
-
const processingQueue = ExuluQueues.register(
|
|
223
|
-
"document-processing",
|
|
224
|
-
{ worker: 3, queue: 5 },
|
|
225
|
-
5, // 5 jobs/sec
|
|
226
|
-
600 // 10 min timeout
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
// Used by processor
|
|
230
|
-
const context = new ExuluContext({
|
|
231
|
-
id: "docs",
|
|
232
|
-
processor: {
|
|
233
|
-
name: "PDF Processor",
|
|
234
|
-
config: {
|
|
235
|
-
queue: await processingQueue.use(),
|
|
236
|
-
trigger: "onInsert"
|
|
237
|
-
},
|
|
238
|
-
execute: async ({ item }) => {
|
|
239
|
-
const text = await extractPDFText(item.file_s3key);
|
|
240
|
-
return { ...item, content: text };
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
```
|
|
245
|
-
</Tab>
|
|
246
|
-
|
|
247
|
-
<Tab title="Scheduled data sync">
|
|
248
|
-
```typescript
|
|
249
|
-
const syncQueue = ExuluQueues.register(
|
|
250
|
-
"data-sync",
|
|
251
|
-
{ worker: 1, queue: 1 },
|
|
252
|
-
1, // 1 job/sec
|
|
253
|
-
1800 // 30 min timeout
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
// Used by ExuluContext source
|
|
257
|
-
const context = new ExuluContext({
|
|
258
|
-
id: "github-issues",
|
|
259
|
-
sources: [{
|
|
260
|
-
id: "github",
|
|
261
|
-
name: "GitHub Sync",
|
|
262
|
-
description: "Syncs issues from GitHub",
|
|
263
|
-
config: {
|
|
264
|
-
schedule: "0 */6 * * *", // Every 6 hours
|
|
265
|
-
queue: await syncQueue.use()
|
|
266
|
-
},
|
|
267
|
-
execute: async () => {
|
|
268
|
-
const issues = await fetchGitHubIssues();
|
|
269
|
-
return issues;
|
|
270
|
-
}
|
|
271
|
-
}]
|
|
272
|
-
});
|
|
273
|
-
```
|
|
274
|
-
</Tab>
|
|
275
|
-
|
|
276
|
-
<Tab title="Agent workflows">
|
|
277
|
-
```typescript
|
|
278
|
-
const workflowQueue = ExuluQueues.register(
|
|
279
|
-
"agent-workflows",
|
|
280
|
-
{ worker: 10, queue: 20 },
|
|
281
|
-
20, // 20 jobs/sec
|
|
282
|
-
300 // 5 min timeout
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
// Used by ExuluAgent
|
|
286
|
-
const agent = new ExuluAgent({
|
|
287
|
-
id: "assistant",
|
|
288
|
-
name: "Assistant",
|
|
289
|
-
workflows: {
|
|
290
|
-
enabled: true,
|
|
291
|
-
queue: await workflowQueue.use()
|
|
292
|
-
}
|
|
293
|
-
// ...
|
|
294
|
-
});
|
|
295
|
-
```
|
|
296
|
-
</Tab>
|
|
297
|
-
</Tabs>
|
|
298
|
-
|
|
299
|
-
## Queue lifecycle
|
|
300
|
-
|
|
301
|
-
<Steps>
|
|
302
|
-
<Step title="Register queue">
|
|
303
|
-
Define queue configuration with `ExuluQueues.register()`
|
|
304
|
-
|
|
305
|
-
```typescript
|
|
306
|
-
const myQueue = ExuluQueues.register("my-queue", {...});
|
|
307
|
-
```
|
|
308
|
-
</Step>
|
|
309
|
-
|
|
310
|
-
<Step title="Initialize queue">
|
|
311
|
-
Call `.use()` to create the BullMQ Queue instance
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
const config = await myQueue.use();
|
|
315
|
-
```
|
|
316
|
-
</Step>
|
|
317
|
-
|
|
318
|
-
<Step title="Add jobs">
|
|
319
|
-
Queue jobs for processing
|
|
320
|
-
|
|
321
|
-
```typescript
|
|
322
|
-
await config.queue.add("job-name", { data: "..." });
|
|
323
|
-
```
|
|
324
|
-
</Step>
|
|
325
|
-
|
|
326
|
-
<Step title="Create workers">
|
|
327
|
-
Start worker processes to handle jobs
|
|
328
|
-
|
|
329
|
-
```typescript
|
|
330
|
-
const worker = new Worker("my-queue", processor, options);
|
|
331
|
-
```
|
|
332
|
-
</Step>
|
|
333
|
-
|
|
334
|
-
<Step title="Process jobs">
|
|
335
|
-
Workers pick up and execute jobs asynchronously
|
|
336
|
-
</Step>
|
|
337
|
-
</Steps>
|
|
338
|
-
|
|
339
|
-
## Integration with ExuluApp
|
|
340
|
-
|
|
341
|
-
ExuluApp automatically creates workers for registered queues:
|
|
342
|
-
|
|
343
|
-
```typescript
|
|
344
|
-
const app = new ExuluApp();
|
|
345
|
-
await app.create({
|
|
346
|
-
config: {
|
|
347
|
-
workers: {
|
|
348
|
-
enabled: true // Creates workers for all queues
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
contexts: {
|
|
352
|
-
docs: docsContext // Context with embedder queue
|
|
353
|
-
},
|
|
354
|
-
agents: {
|
|
355
|
-
assistant: agent // Agent with workflow queue
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
// Workers are automatically created and started
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
When `workers.enabled: true`, ExuluApp:
|
|
363
|
-
1. Discovers all queues from contexts, agents, and embedders
|
|
364
|
-
2. Creates Worker instances for each queue
|
|
365
|
-
3. Configures concurrency and rate limits
|
|
366
|
-
4. Starts processing jobs
|
|
367
|
-
|
|
368
|
-
## Job states
|
|
369
|
-
|
|
370
|
-
Jobs move through these states:
|
|
371
|
-
|
|
372
|
-
```
|
|
373
|
-
waiting → active → completed
|
|
374
|
-
↓
|
|
375
|
-
failed → waiting (retry)
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
- **waiting**: Job is queued, not yet picked up
|
|
379
|
-
- **active**: Worker is currently processing
|
|
380
|
-
- **completed**: Job finished successfully
|
|
381
|
-
- **failed**: Job threw an error
|
|
382
|
-
|
|
383
|
-
Failed jobs automatically retry based on configuration.
|
|
384
|
-
|
|
385
|
-
## Monitoring
|
|
386
|
-
|
|
387
|
-
### Built-in telemetry
|
|
388
|
-
|
|
389
|
-
ExuluQueues includes OpenTelemetry integration:
|
|
390
|
-
|
|
391
|
-
```typescript
|
|
392
|
-
import { BullMQOtel } from "bullmq-otel";
|
|
393
|
-
|
|
394
|
-
const queue = new Queue("my-queue", {
|
|
395
|
-
telemetry: new BullMQOtel("exulu-app")
|
|
396
|
-
});
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
This tracks:
|
|
400
|
-
- Job duration
|
|
401
|
-
- Success/failure rates
|
|
402
|
-
- Queue depth
|
|
403
|
-
- Processing latency
|
|
404
|
-
|
|
405
|
-
### Queue inspection
|
|
406
|
-
|
|
407
|
-
Check queue status programmatically:
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
const config = await myQueue.use();
|
|
411
|
-
|
|
412
|
-
// Get job counts
|
|
413
|
-
const counts = await config.queue.getJobCounts();
|
|
414
|
-
console.log(counts);
|
|
415
|
-
// { waiting: 5, active: 2, completed: 100, failed: 3 }
|
|
416
|
-
|
|
417
|
-
// Get specific jobs
|
|
418
|
-
const failedJobs = await config.queue.getFailed();
|
|
419
|
-
const activeJobs = await config.queue.getActive();
|
|
420
|
-
|
|
421
|
-
// Get queue metrics
|
|
422
|
-
const concurrency = await config.queue.getGlobalConcurrency();
|
|
423
|
-
console.log(`Global concurrency: ${concurrency}`);
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
## Best practices
|
|
427
|
-
|
|
428
|
-
<Tip>
|
|
429
|
-
**Right-size concurrency**: Start with low concurrency and increase gradually. Monitor CPU/memory usage and adjust.
|
|
430
|
-
</Tip>
|
|
431
|
-
|
|
432
|
-
<Note>
|
|
433
|
-
**Configure timeouts**: Set realistic timeouts based on expected job duration. Too short = premature failures, too long = stuck workers.
|
|
434
|
-
</Note>
|
|
435
|
-
|
|
436
|
-
<Warning>
|
|
437
|
-
**Redis is required**: Queues require a Redis server. Ensure Redis is configured before using queues.
|
|
438
|
-
</Warning>
|
|
439
|
-
|
|
440
|
-
<Info>
|
|
441
|
-
**Rate limits**: Set rate limits based on external service constraints (API limits, database capacity, LLM rate limits).
|
|
442
|
-
</Info>
|
|
443
|
-
|
|
444
|
-
## Redis configuration
|
|
445
|
-
|
|
446
|
-
ExuluQueues requires Redis connection info:
|
|
447
|
-
|
|
448
|
-
```bash
|
|
449
|
-
# Environment variables
|
|
450
|
-
REDIS_HOST=localhost
|
|
451
|
-
REDIS_PORT=6379
|
|
452
|
-
REDIS_PASSWORD=optional-password
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
Or configure programmatically:
|
|
456
|
-
|
|
457
|
-
```typescript
|
|
458
|
-
import { redisServer } from "@exulu/backend";
|
|
459
|
-
|
|
460
|
-
redisServer.host = "localhost";
|
|
461
|
-
redisServer.port = "6379";
|
|
462
|
-
redisServer.password = "optional-password";
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
## Next steps
|
|
466
|
-
|
|
467
|
-
<CardGroup cols={2}>
|
|
468
|
-
<Card title="Configuration" icon="gear" href="/core/exulu-queues/configuration">
|
|
469
|
-
Learn about queue configuration options
|
|
470
|
-
</Card>
|
|
471
|
-
<Card title="API reference" icon="code" href="/core/exulu-queues/api-reference">
|
|
472
|
-
Explore methods and properties
|
|
473
|
-
</Card>
|
|
474
|
-
</CardGroup>
|