@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.
Files changed (164) hide show
  1. package/dist/index.cjs +351 -42
  2. package/dist/index.d.cts +96 -1
  3. package/dist/index.d.ts +96 -1
  4. package/dist/index.js +340 -38
  5. package/ee/{markdown.ts → chunking/markdown.ts} +2 -2
  6. package/ee/python/README.md +295 -0
  7. package/ee/python/documents/processing/README.md +155 -0
  8. package/ee/{documents → python/documents}/processing/doc_processor.ts +25 -17
  9. package/ee/{documents/processing/pdf_to_markdown.py → python/documents/processing/document_to_markdown.py} +3 -10
  10. package/ee/python/setup.sh +180 -0
  11. package/package.json +14 -3
  12. package/scripts/postinstall.cjs +149 -0
  13. package/.agents/skills/mintlify/SKILL.md +0 -347
  14. package/.editorconfig +0 -15
  15. package/.eslintrc.json +0 -52
  16. package/.github/workflows/release-backend.yml +0 -38
  17. package/.husky/commit-msg +0 -1
  18. package/.jscpd.json +0 -18
  19. package/.mcp.json +0 -25
  20. package/.nvmrc +0 -1
  21. package/.prettierignore +0 -5
  22. package/.prettierrc.json +0 -12
  23. package/CHANGELOG.md +0 -8
  24. package/SECURITY.md +0 -5
  25. package/commitlint.config.js +0 -4
  26. package/devops/documentation/patch-older-releases.md +0 -42
  27. package/ee/documents/processing/build_pdf_processor.sh +0 -35
  28. package/ee/documents/processing/chunk_markdown.py +0 -263
  29. package/ee/documents/processing/pdf_processor.spec +0 -115
  30. package/eslint.config.js +0 -88
  31. package/jest.config.ts +0 -25
  32. package/mintlify-docs/.mintignore +0 -7
  33. package/mintlify-docs/AGENTS.md +0 -33
  34. package/mintlify-docs/CLAUDE.MD +0 -50
  35. package/mintlify-docs/CONTRIBUTING.md +0 -32
  36. package/mintlify-docs/LICENSE +0 -21
  37. package/mintlify-docs/README.md +0 -55
  38. package/mintlify-docs/ai-tools/claude-code.mdx +0 -43
  39. package/mintlify-docs/ai-tools/cursor.mdx +0 -39
  40. package/mintlify-docs/ai-tools/windsurf.mdx +0 -39
  41. package/mintlify-docs/api-reference/core-types/agent-types.mdx +0 -110
  42. package/mintlify-docs/api-reference/core-types/analytics-types.mdx +0 -95
  43. package/mintlify-docs/api-reference/core-types/configuration-types.mdx +0 -83
  44. package/mintlify-docs/api-reference/core-types/evaluation-types.mdx +0 -106
  45. package/mintlify-docs/api-reference/core-types/job-types.mdx +0 -135
  46. package/mintlify-docs/api-reference/core-types/overview.mdx +0 -73
  47. package/mintlify-docs/api-reference/core-types/prompt-types.mdx +0 -102
  48. package/mintlify-docs/api-reference/core-types/rbac-types.mdx +0 -163
  49. package/mintlify-docs/api-reference/core-types/session-types.mdx +0 -77
  50. package/mintlify-docs/api-reference/core-types/user-management.mdx +0 -112
  51. package/mintlify-docs/api-reference/core-types/workflow-types.mdx +0 -88
  52. package/mintlify-docs/api-reference/core-types.mdx +0 -585
  53. package/mintlify-docs/api-reference/dynamic-types.mdx +0 -851
  54. package/mintlify-docs/api-reference/endpoint/create.mdx +0 -4
  55. package/mintlify-docs/api-reference/endpoint/delete.mdx +0 -4
  56. package/mintlify-docs/api-reference/endpoint/get.mdx +0 -4
  57. package/mintlify-docs/api-reference/endpoint/webhook.mdx +0 -4
  58. package/mintlify-docs/api-reference/introduction.mdx +0 -661
  59. package/mintlify-docs/api-reference/mutations.mdx +0 -1012
  60. package/mintlify-docs/api-reference/openapi.json +0 -217
  61. package/mintlify-docs/api-reference/queries.mdx +0 -1154
  62. package/mintlify-docs/backend/introduction.mdx +0 -218
  63. package/mintlify-docs/changelog.mdx +0 -387
  64. package/mintlify-docs/community-edition.mdx +0 -304
  65. package/mintlify-docs/core/exulu-agent/api-reference.mdx +0 -894
  66. package/mintlify-docs/core/exulu-agent/configuration.mdx +0 -690
  67. package/mintlify-docs/core/exulu-agent/introduction.mdx +0 -552
  68. package/mintlify-docs/core/exulu-app/api-reference.mdx +0 -481
  69. package/mintlify-docs/core/exulu-app/configuration.mdx +0 -319
  70. package/mintlify-docs/core/exulu-app/introduction.mdx +0 -117
  71. package/mintlify-docs/core/exulu-authentication.mdx +0 -810
  72. package/mintlify-docs/core/exulu-chunkers/api-reference.mdx +0 -1011
  73. package/mintlify-docs/core/exulu-chunkers/configuration.mdx +0 -596
  74. package/mintlify-docs/core/exulu-chunkers/introduction.mdx +0 -403
  75. package/mintlify-docs/core/exulu-context/api-reference.mdx +0 -911
  76. package/mintlify-docs/core/exulu-context/configuration.mdx +0 -648
  77. package/mintlify-docs/core/exulu-context/introduction.mdx +0 -394
  78. package/mintlify-docs/core/exulu-database.mdx +0 -811
  79. package/mintlify-docs/core/exulu-default-agents.mdx +0 -545
  80. package/mintlify-docs/core/exulu-eval/api-reference.mdx +0 -772
  81. package/mintlify-docs/core/exulu-eval/configuration.mdx +0 -680
  82. package/mintlify-docs/core/exulu-eval/introduction.mdx +0 -459
  83. package/mintlify-docs/core/exulu-logging.mdx +0 -464
  84. package/mintlify-docs/core/exulu-otel.mdx +0 -670
  85. package/mintlify-docs/core/exulu-queues/api-reference.mdx +0 -648
  86. package/mintlify-docs/core/exulu-queues/configuration.mdx +0 -650
  87. package/mintlify-docs/core/exulu-queues/introduction.mdx +0 -474
  88. package/mintlify-docs/core/exulu-reranker/api-reference.mdx +0 -630
  89. package/mintlify-docs/core/exulu-reranker/configuration.mdx +0 -663
  90. package/mintlify-docs/core/exulu-reranker/introduction.mdx +0 -516
  91. package/mintlify-docs/core/exulu-tool/api-reference.mdx +0 -723
  92. package/mintlify-docs/core/exulu-tool/configuration.mdx +0 -805
  93. package/mintlify-docs/core/exulu-tool/introduction.mdx +0 -539
  94. package/mintlify-docs/core/exulu-variables/api-reference.mdx +0 -699
  95. package/mintlify-docs/core/exulu-variables/configuration.mdx +0 -736
  96. package/mintlify-docs/core/exulu-variables/introduction.mdx +0 -511
  97. package/mintlify-docs/development.mdx +0 -94
  98. package/mintlify-docs/docs.json +0 -248
  99. package/mintlify-docs/enterprise-edition.mdx +0 -538
  100. package/mintlify-docs/essentials/code.mdx +0 -35
  101. package/mintlify-docs/essentials/images.mdx +0 -59
  102. package/mintlify-docs/essentials/markdown.mdx +0 -88
  103. package/mintlify-docs/essentials/navigation.mdx +0 -87
  104. package/mintlify-docs/essentials/reusable-snippets.mdx +0 -110
  105. package/mintlify-docs/essentials/settings.mdx +0 -318
  106. package/mintlify-docs/favicon.svg +0 -3
  107. package/mintlify-docs/frontend/introduction.mdx +0 -39
  108. package/mintlify-docs/getting-started.mdx +0 -267
  109. package/mintlify-docs/guides/custom-agent.mdx +0 -608
  110. package/mintlify-docs/guides/first-agent.mdx +0 -315
  111. package/mintlify-docs/images/admin_ui.png +0 -0
  112. package/mintlify-docs/images/contexts.png +0 -0
  113. package/mintlify-docs/images/create_agents.png +0 -0
  114. package/mintlify-docs/images/evals.png +0 -0
  115. package/mintlify-docs/images/graphql.png +0 -0
  116. package/mintlify-docs/images/graphql_api.png +0 -0
  117. package/mintlify-docs/images/hero-dark.png +0 -0
  118. package/mintlify-docs/images/hero-light.png +0 -0
  119. package/mintlify-docs/images/hero.png +0 -0
  120. package/mintlify-docs/images/knowledge_sources.png +0 -0
  121. package/mintlify-docs/images/mcp.png +0 -0
  122. package/mintlify-docs/images/scaling.png +0 -0
  123. package/mintlify-docs/index.mdx +0 -411
  124. package/mintlify-docs/logo/dark.svg +0 -9
  125. package/mintlify-docs/logo/light.svg +0 -9
  126. package/mintlify-docs/partners.mdx +0 -558
  127. package/mintlify-docs/products.mdx +0 -77
  128. package/mintlify-docs/snippets/snippet-intro.mdx +0 -4
  129. package/mintlify-docs/styles.css +0 -207
  130. package/ngrok.bash +0 -1
  131. package/ngrok.md +0 -6
  132. package/ngrok.yml +0 -10
  133. package/release.config.cjs +0 -15
  134. package/skills-lock.json +0 -10
  135. package/types/context-processor.ts +0 -45
  136. package/types/enums/eval-types.ts +0 -5
  137. package/types/enums/field-types.ts +0 -1
  138. package/types/enums/jobs.ts +0 -11
  139. package/types/enums/statistics.ts +0 -13
  140. package/types/exulu-table-definition.ts +0 -79
  141. package/types/file-types.ts +0 -18
  142. package/types/models/agent-session.ts +0 -27
  143. package/types/models/agent.ts +0 -68
  144. package/types/models/context.ts +0 -53
  145. package/types/models/embedding.ts +0 -17
  146. package/types/models/eval-run.ts +0 -40
  147. package/types/models/exulu-agent-tool-config.ts +0 -11
  148. package/types/models/item.ts +0 -21
  149. package/types/models/job.ts +0 -8
  150. package/types/models/project.ts +0 -16
  151. package/types/models/rate-limiter-rules.ts +0 -7
  152. package/types/models/test-case.ts +0 -25
  153. package/types/models/tool.ts +0 -9
  154. package/types/models/user-role.ts +0 -12
  155. package/types/models/user.ts +0 -20
  156. package/types/models/variable.ts +0 -8
  157. package/types/models/vector-methods.ts +0 -7
  158. package/types/provider-config.ts +0 -21
  159. package/types/queue-config.ts +0 -16
  160. package/types/rbac-rights-modes.ts +0 -1
  161. package/types/statistics.ts +0 -20
  162. package/types/workflow.ts +0 -31
  163. /package/ee/{documents → python/documents}/THIRD_PARTY_LICENSES/docling.txt +0 -0
  164. /package/ee/{documents/processing → python}/requirements.txt +0 -0
@@ -1,648 +0,0 @@
1
- ---
2
- title: "API reference"
3
- description: "Complete method and property reference for ExuluQueues"
4
- ---
5
-
6
- ## Singleton instance
7
-
8
- ExuluQueues is exported as a singleton instance:
9
-
10
- ```typescript
11
- import { ExuluQueues } from "@exulu/backend";
12
-
13
- // Use the singleton directly
14
- const myQueue = ExuluQueues.register("my-queue", ...);
15
- ```
16
-
17
- ## Methods
18
-
19
- ### register()
20
-
21
- Registers a new queue with specified configuration.
22
-
23
- ```typescript
24
- ExuluQueues.register(
25
- name: string,
26
- concurrency: { worker: number; queue: number },
27
- ratelimit?: number,
28
- timeoutInSeconds?: number
29
- ): {
30
- use: () => Promise<ExuluQueueConfig>
31
- }
32
- ```
33
-
34
- <ParamField path="name" type="string" required>
35
- Unique queue name
36
- </ParamField>
37
-
38
- <ParamField path="concurrency" type="object" required>
39
- Concurrency configuration with worker and queue levels
40
- </ParamField>
41
-
42
- <ParamField path="concurrency.worker" type="number" required>
43
- Jobs per worker process
44
- </ParamField>
45
-
46
- <ParamField path="concurrency.queue" type="number" required>
47
- Global max jobs across all workers
48
- </ParamField>
49
-
50
- <ParamField path="ratelimit" type="number" default={1}>
51
- Maximum jobs per second (default: 1)
52
- </ParamField>
53
-
54
- <ParamField path="timeoutInSeconds" type="number" default={180}>
55
- Job timeout in seconds (default: 180)
56
- </ParamField>
57
-
58
- <ResponseField name="return" type="{ use: () => Promise<ExuluQueueConfig> }">
59
- Object with `use()` method to initialize the queue
60
- </ResponseField>
61
-
62
- ```typescript
63
- import { ExuluQueues } from "@exulu/backend";
64
-
65
- // Register a queue
66
- const embeddingsQueue = ExuluQueues.register(
67
- "embeddings", // name
68
- {
69
- worker: 5, // worker concurrency
70
- queue: 10 // queue concurrency
71
- },
72
- 10, // rate limit: 10 jobs/sec
73
- 300 // timeout: 5 minutes
74
- );
75
-
76
- // Initialize the queue
77
- const config = await embeddingsQueue.use();
78
-
79
- // Add jobs
80
- await config.queue.add("generate-embeddings", {
81
- contextId: "docs",
82
- itemId: "item-123"
83
- });
84
- ```
85
-
86
- <Note>
87
- `register()` only registers the queue configuration. Call `.use()` to actually create the BullMQ Queue instance.
88
- </Note>
89
-
90
- ### queue()
91
-
92
- Retrieves a queue configuration by name.
93
-
94
- ```typescript
95
- ExuluQueues.queue(name: string): {
96
- queue: Queue;
97
- ratelimit: number;
98
- concurrency: {
99
- worker: number;
100
- queue: number;
101
- };
102
- } | undefined
103
- ```
104
-
105
- <ParamField path="name" type="string" required>
106
- Queue name to retrieve
107
- </ParamField>
108
-
109
- <ResponseField name="return" type="QueueConfig | undefined">
110
- Queue configuration object, or undefined if not found
111
- </ResponseField>
112
-
113
- ```typescript
114
- // Get a previously registered queue
115
- const config = ExuluQueues.queue("embeddings");
116
-
117
- if (config) {
118
- console.log(config.queue.name); // "embeddings"
119
- console.log(config.ratelimit); // 10
120
- console.log(config.concurrency.worker); // 5
121
- console.log(config.concurrency.queue); // 10
122
- }
123
- ```
124
-
125
- <Info>
126
- Use this to access queues that were registered elsewhere in your application.
127
- </Info>
128
-
129
- ## Properties
130
-
131
- ### queues
132
-
133
- <ResponseField name="queues" type="QueueConfig[]">
134
- Array of all initialized queue configurations
135
- </ResponseField>
136
-
137
- ```typescript
138
- // Access all queues
139
- ExuluQueues.queues.forEach(config => {
140
- console.log(`Queue: ${config.queue.name}`);
141
- console.log(`Rate limit: ${config.ratelimit} jobs/sec`);
142
- console.log(`Worker concurrency: ${config.concurrency.worker}`);
143
- console.log(`Queue concurrency: ${config.concurrency.queue}`);
144
- console.log(`Timeout: ${config.timeoutInSeconds}s`);
145
- });
146
- ```
147
-
148
- ### list
149
-
150
- <ResponseField name="list" type="Map<string, QueueRegistration>">
151
- Map of registered queue configurations (before initialization)
152
- </ResponseField>
153
-
154
- ```typescript
155
- // Access registered queues
156
- const registration = ExuluQueues.list.get("embeddings");
157
-
158
- if (registration) {
159
- console.log(registration.name); // "embeddings"
160
- console.log(registration.concurrency.worker); // 5
161
- console.log(registration.concurrency.queue); // 10
162
- console.log(registration.ratelimit); // 10
163
- console.log(registration.timeoutInSeconds); // 300
164
-
165
- // Initialize the queue
166
- const config = await registration.use();
167
- }
168
-
169
- // List all registered queues
170
- for (const [name, registration] of ExuluQueues.list) {
171
- console.log(`Registered queue: ${name}`);
172
- }
173
- ```
174
-
175
- ## Queue configuration object
176
-
177
- When you call `.use()`, you get an `ExuluQueueConfig` object:
178
-
179
- ```typescript
180
- type ExuluQueueConfig = {
181
- queue: Queue; // BullMQ Queue instance
182
- ratelimit: number; // Jobs per second
183
- timeoutInSeconds: number; // Job timeout
184
- concurrency: {
185
- worker: number; // Per-worker concurrency
186
- queue: number; // Global concurrency
187
- };
188
- retries?: number; // Optional: retry count
189
- backoff?: { // Optional: backoff strategy
190
- type: "exponential" | "linear";
191
- delay: number;
192
- };
193
- };
194
- ```
195
-
196
- ### Using the Queue instance
197
-
198
- The `queue` property is a BullMQ Queue instance with full API access:
199
-
200
- ```typescript
201
- const config = await myQueue.use();
202
-
203
- // Add jobs
204
- await config.queue.add("job-name", { data: "..." });
205
-
206
- // Add delayed jobs
207
- await config.queue.add("job-name", { data: "..." }, {
208
- delay: 5000 // Delay 5 seconds
209
- });
210
-
211
- // Add scheduled jobs
212
- await config.queue.add("job-name", { data: "..." }, {
213
- repeat: {
214
- pattern: "0 0 * * *" // Daily at midnight
215
- }
216
- });
217
-
218
- // Get job counts
219
- const counts = await config.queue.getJobCounts();
220
- console.log(counts);
221
- // { waiting: 5, active: 2, completed: 100, failed: 3 }
222
-
223
- // Get jobs
224
- const waitingJobs = await config.queue.getWaiting();
225
- const activeJobs = await config.queue.getActive();
226
- const completedJobs = await config.queue.getCompleted();
227
- const failedJobs = await config.queue.getFailed();
228
-
229
- // Get queue metrics
230
- const concurrency = await config.queue.getGlobalConcurrency();
231
- console.log(`Global concurrency: ${concurrency}`);
232
-
233
- // Update global concurrency
234
- await config.queue.setGlobalConcurrency(20);
235
-
236
- // Pause/resume queue
237
- await config.queue.pause();
238
- await config.queue.resume();
239
-
240
- // Remove jobs
241
- await config.queue.clean(24 * 3600 * 1000, 0, "completed"); // Remove completed jobs older than 24h
242
-
243
- // Drain queue (remove all waiting jobs)
244
- await config.queue.drain();
245
-
246
- // Close queue
247
- await config.queue.close();
248
- ```
249
-
250
- ## Usage examples
251
-
252
- ### Basic queue registration and usage
253
-
254
- ```typescript
255
- import { ExuluQueues } from "@exulu/backend";
256
-
257
- // Register queue
258
- const myQueue = ExuluQueues.register(
259
- "my-queue",
260
- { worker: 5, queue: 10 },
261
- 10,
262
- 180
263
- );
264
-
265
- // Initialize
266
- const config = await myQueue.use();
267
-
268
- // Add a job
269
- await config.queue.add("process-item", {
270
- itemId: "123",
271
- action: "process"
272
- });
273
-
274
- // Add a job with options
275
- await config.queue.add(
276
- "process-item",
277
- { itemId: "456" },
278
- {
279
- priority: 1, // Higher priority
280
- delay: 5000, // Delay 5 seconds
281
- attempts: 3, // Retry 3 times
282
- backoff: {
283
- type: "exponential",
284
- delay: 1000
285
- }
286
- }
287
- );
288
- ```
289
-
290
- ### With ExuluEmbedder
291
-
292
- ```typescript
293
- import { ExuluQueues, ExuluEmbedder } from "@exulu/backend";
294
-
295
- // Register queue for embeddings
296
- const embeddingsQueue = ExuluQueues.register(
297
- "embeddings",
298
- { worker: 5, queue: 10 },
299
- 10, // 10 jobs/sec
300
- 300 // 5 min timeout
301
- );
302
-
303
- // Create embedder with queue
304
- const embedder = new ExuluEmbedder({
305
- id: "openai_embedder",
306
- name: "OpenAI Embeddings",
307
- provider: "openai",
308
- model: "text-embedding-3-small",
309
- vectorDimensions: 1536,
310
- queue: await embeddingsQueue.use()
311
- });
312
-
313
- // Embeddings are now queued automatically
314
- const context = new ExuluContext({
315
- id: "docs",
316
- embedder: embedder,
317
- // ...
318
- });
319
-
320
- await context.createItem(item, config);
321
- // Embeddings generation is queued, not blocking
322
- ```
323
-
324
- ### With ExuluContext processor
325
-
326
- ```typescript
327
- import { ExuluQueues, ExuluContext } from "@exulu/backend";
328
-
329
- // Register processing queue
330
- const processingQueue = ExuluQueues.register(
331
- "document-processing",
332
- { worker: 3, queue: 5 },
333
- 5, // 5 jobs/sec
334
- 600 // 10 min timeout
335
- );
336
-
337
- // Use in context processor
338
- const context = new ExuluContext({
339
- id: "documents",
340
- processor: {
341
- name: "PDF Text Extractor",
342
- config: {
343
- queue: await processingQueue.use(),
344
- trigger: "onInsert",
345
- generateEmbeddings: true,
346
- timeoutInSeconds: 600,
347
- retries: 3,
348
- backoff: {
349
- type: "exponential",
350
- delay: 2000
351
- }
352
- },
353
- execute: async ({ item, utils }) => {
354
- const text = await utils.storage.extractText(item.document_s3key);
355
- return { ...item, content: text };
356
- }
357
- },
358
- fields: [
359
- { name: "title", type: "text", required: true },
360
- { name: "document", type: "file", allowedFileTypes: [".pdf"] },
361
- { name: "content", type: "longtext" }
362
- ],
363
- sources: []
364
- });
365
- ```
366
-
367
- ### With ExuluContext data source
368
-
369
- ```typescript
370
- import { ExuluQueues, ExuluContext } from "@exulu/backend";
371
-
372
- // Register sync queue
373
- const syncQueue = ExuluQueues.register(
374
- "github-sync",
375
- { worker: 1, queue: 1 },
376
- 1, // 1 job/sec
377
- 1800 // 30 min timeout
378
- );
379
-
380
- // Use in context source
381
- const context = new ExuluContext({
382
- id: "github_issues",
383
- sources: [{
384
- id: "github",
385
- name: "GitHub Issues Sync",
386
- description: "Syncs issues from GitHub repository",
387
- config: {
388
- schedule: "0 */6 * * *", // Every 6 hours
389
- queue: await syncQueue.use(),
390
- retries: 3,
391
- backoff: {
392
- type: "exponential",
393
- delay: 2000
394
- }
395
- },
396
- execute: async ({ exuluConfig }) => {
397
- const issues = await fetchGitHubIssues();
398
- return issues.map(issue => ({
399
- external_id: issue.id,
400
- name: issue.title,
401
- content: issue.body,
402
- metadata: { labels: issue.labels }
403
- }));
404
- }
405
- }],
406
- fields: [
407
- { name: "title", type: "text", required: true },
408
- { name: "content", type: "longtext", required: true },
409
- { name: "metadata", type: "json" }
410
- ]
411
- });
412
- ```
413
-
414
- ### With ExuluAgent workflows
415
-
416
- ```typescript
417
- import { ExuluQueues, ExuluAgent } from "@exulu/backend";
418
- import { createOpenAI } from "@ai-sdk/openai";
419
-
420
- // Register workflow queue
421
- const workflowQueue = ExuluQueues.register(
422
- "agent-workflows",
423
- { worker: 10, queue: 20 },
424
- 20, // 20 jobs/sec
425
- 300 // 5 min timeout
426
- );
427
-
428
- // Use in agent
429
- const agent = new ExuluAgent({
430
- id: "assistant",
431
- name: "Assistant",
432
- type: "agent",
433
- description: "AI assistant with background workflows",
434
- provider: "openai",
435
- config: {
436
- name: "gpt-4o",
437
- model: {
438
- create: ({ apiKey }) => createOpenAI({ apiKey })("gpt-4o")
439
- },
440
- instructions: "You are a helpful assistant."
441
- },
442
- workflows: {
443
- enabled: true,
444
- queue: await workflowQueue.use()
445
- },
446
- capabilities: {
447
- text: true,
448
- images: [],
449
- files: [],
450
- audio: [],
451
- video: []
452
- }
453
- });
454
- ```
455
-
456
- ### Monitoring queue status
457
-
458
- ```typescript
459
- const config = await myQueue.use();
460
-
461
- // Get job counts
462
- const counts = await config.queue.getJobCounts();
463
- console.log(`Waiting: ${counts.waiting}`);
464
- console.log(`Active: ${counts.active}`);
465
- console.log(`Completed: ${counts.completed}`);
466
- console.log(`Failed: ${counts.failed}`);
467
-
468
- // Get failed jobs
469
- const failedJobs = await config.queue.getFailed();
470
- for (const job of failedJobs) {
471
- console.log(`Job ${job.id} failed:`, job.failedReason);
472
- console.log(`Data:`, job.data);
473
- console.log(`Attempts: ${job.attemptsMade}/${job.opts.attempts}`);
474
- }
475
-
476
- // Get active jobs
477
- const activeJobs = await config.queue.getActive();
478
- console.log(`Currently processing ${activeJobs.length} jobs`);
479
-
480
- // Check global concurrency
481
- const concurrency = await config.queue.getGlobalConcurrency();
482
- console.log(`Global concurrency: ${concurrency}`);
483
- ```
484
-
485
- ### Managing queue lifecycle
486
-
487
- ```typescript
488
- const config = await myQueue.use();
489
-
490
- // Pause processing (workers stop picking up new jobs)
491
- await config.queue.pause();
492
- console.log("Queue paused");
493
-
494
- // Resume processing
495
- await config.queue.resume();
496
- console.log("Queue resumed");
497
-
498
- // Clean old completed jobs
499
- await config.queue.clean(
500
- 24 * 3600 * 1000, // Older than 24 hours
501
- 100, // Max 100 jobs
502
- "completed" // Job type
503
- );
504
-
505
- // Clean old failed jobs
506
- await config.queue.clean(
507
- 7 * 24 * 3600 * 1000, // Older than 7 days
508
- 0, // All jobs
509
- "failed"
510
- );
511
-
512
- // Drain all waiting jobs
513
- await config.queue.drain();
514
- console.log("All waiting jobs removed");
515
-
516
- // Close queue connection
517
- await config.queue.close();
518
- ```
519
-
520
- ### Multiple queues
521
-
522
- ```typescript
523
- // Register multiple queues for different purposes
524
- const embeddingsQueue = ExuluQueues.register(
525
- "embeddings",
526
- { worker: 5, queue: 10 },
527
- 10,
528
- 300
529
- );
530
-
531
- const processingQueue = ExuluQueues.register(
532
- "processing",
533
- { worker: 3, queue: 5 },
534
- 5,
535
- 600
536
- );
537
-
538
- const syncQueue = ExuluQueues.register(
539
- "sync",
540
- { worker: 1, queue: 1 },
541
- 1,
542
- 1800
543
- );
544
-
545
- // Initialize all queues
546
- const [embeddingsConfig, processingConfig, syncConfig] = await Promise.all([
547
- embeddingsQueue.use(),
548
- processingQueue.use(),
549
- syncQueue.use()
550
- ]);
551
-
552
- // Use them independently
553
- await embeddingsConfig.queue.add("embed", { ... });
554
- await processingConfig.queue.add("process", { ... });
555
- await syncConfig.queue.add("sync", { ... });
556
-
557
- // Monitor all queues
558
- for (const queueConfig of ExuluQueues.queues) {
559
- const counts = await queueConfig.queue.getJobCounts();
560
- console.log(`${queueConfig.queue.name}:`, counts);
561
- }
562
- ```
563
-
564
- ### Retrieving registered queues
565
-
566
- ```typescript
567
- // Later in your code, retrieve a queue by name
568
- const config = ExuluQueues.queue("embeddings");
569
-
570
- if (config) {
571
- // Add a job to the existing queue
572
- await config.queue.add("new-job", { data: "..." });
573
- }
574
-
575
- // List all registered queues
576
- for (const [name, registration] of ExuluQueues.list) {
577
- console.log(`Queue: ${name}`);
578
- console.log(` Worker concurrency: ${registration.concurrency.worker}`);
579
- console.log(` Queue concurrency: ${registration.concurrency.queue}`);
580
- console.log(` Rate limit: ${registration.ratelimit} jobs/sec`);
581
- console.log(` Timeout: ${registration.timeoutInSeconds}s`);
582
- }
583
- ```
584
-
585
- ## Type definitions
586
-
587
- ```typescript
588
- // Queue registration return type
589
- type QueueRegistration = {
590
- use: () => Promise<ExuluQueueConfig>;
591
- };
592
-
593
- // Queue configuration after initialization
594
- type ExuluQueueConfig = {
595
- queue: Queue; // BullMQ Queue instance
596
- ratelimit: number; // Jobs per second
597
- timeoutInSeconds: number; // Job timeout
598
- concurrency: {
599
- worker: number; // Per-worker concurrency
600
- queue: number; // Global concurrency
601
- };
602
- retries?: number; // Optional retry count
603
- backoff?: { // Optional backoff strategy
604
- type: "exponential" | "linear";
605
- delay: number; // Milliseconds
606
- };
607
- };
608
-
609
- // Queue config in ExuluQueues.queues array
610
- type QueueConfig = {
611
- queue: Queue;
612
- ratelimit: number;
613
- concurrency: {
614
- worker: number;
615
- queue: number;
616
- };
617
- timeoutInSeconds: number;
618
- };
619
- ```
620
-
621
- ## Best practices
622
-
623
- <Tip>
624
- **Initialize queues early**: Call `.use()` during application startup to ensure queues are ready before they're needed.
625
- </Tip>
626
-
627
- <Note>
628
- **Reuse queue configurations**: Register queues once and retrieve them with `ExuluQueues.queue()` when needed elsewhere.
629
- </Note>
630
-
631
- <Warning>
632
- **Close queues on shutdown**: Properly close queue connections when shutting down your application to prevent resource leaks.
633
- </Warning>
634
-
635
- <Info>
636
- **Monitor queue depth**: Regularly check job counts to ensure queues aren't backing up. High `waiting` counts indicate you need more throughput.
637
- </Info>
638
-
639
- ## Next steps
640
-
641
- <CardGroup cols={2}>
642
- <Card title="Configuration guide" icon="gear" href="/core/exulu-queues/configuration">
643
- Learn about queue configuration
644
- </Card>
645
- <Card title="ExuluContext" icon="database" href="/core/exulu-context/introduction">
646
- See how contexts use queues
647
- </Card>
648
- </CardGroup>