bunqueue 2.8.43 → 2.8.45
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/README.md +3 -3
- package/dist/application/latencyTracker.js +3 -3
- package/dist/application/metricsExporter.d.ts +3 -1
- package/dist/application/metricsExporter.js +63 -16
- package/dist/application/prometheusOperationalMetrics.d.ts +31 -0
- package/dist/application/prometheusOperationalMetrics.js +53 -0
- package/dist/application/queueManager.d.ts +6 -0
- package/dist/application/queueManager.js +24 -1
- package/dist/application/types.d.ts +3 -0
- package/dist/application/types.js +1 -0
- package/dist/application/workerManager.d.ts +1 -0
- package/dist/application/workerManager.js +4 -1
- package/dist/cli/help.js +2 -2
- package/dist/cli/output.js +2 -1
- package/dist/config/resolve.d.ts +1 -0
- package/dist/config/resolve.js +10 -0
- package/dist/config/types.d.ts +6 -0
- package/dist/infrastructure/backup/backupTelemetry.d.ts +30 -0
- package/dist/infrastructure/backup/backupTelemetry.js +63 -0
- package/dist/infrastructure/backup/index.d.ts +1 -1
- package/dist/infrastructure/backup/index.js +1 -1
- package/dist/infrastructure/backup/s3Backup.d.ts +6 -2
- package/dist/infrastructure/backup/s3Backup.js +22 -9
- package/dist/infrastructure/backup/s3BackupConfig.d.ts +7 -0
- package/dist/infrastructure/backup/s3BackupConfig.js +5 -0
- package/dist/infrastructure/backup/s3BackupIo.d.ts +23 -0
- package/dist/infrastructure/backup/s3BackupIo.js +106 -0
- package/dist/infrastructure/backup/s3BackupOperations.d.ts +6 -15
- package/dist/infrastructure/backup/s3BackupOperations.js +139 -259
- package/dist/infrastructure/backup/sqliteBackupFiles.d.ts +22 -0
- package/dist/infrastructure/backup/sqliteBackupFiles.js +130 -0
- package/dist/infrastructure/cloud/statsRefresh.d.ts +1 -0
- package/dist/infrastructure/persistence/sqlite.js +6 -1
- package/dist/infrastructure/server/bootstrap.d.ts +2 -0
- package/dist/infrastructure/server/bootstrap.js +49 -14
- package/dist/infrastructure/server/http.d.ts +2 -0
- package/dist/infrastructure/server/http.js +9 -58
- package/dist/infrastructure/server/httpDashboardEndpoints.d.ts +10 -0
- package/dist/infrastructure/server/httpDashboardEndpoints.js +146 -0
- package/dist/infrastructure/server/httpEndpoints.d.ts +5 -9
- package/dist/infrastructure/server/httpEndpoints.js +16 -160
- package/dist/infrastructure/server/httpResponse.d.ts +2 -0
- package/dist/infrastructure/server/httpResponse.js +12 -0
- package/dist/infrastructure/server/httpRouter.d.ts +6 -0
- package/dist/infrastructure/server/httpRouter.js +50 -0
- package/dist/shared/histogram.d.ts +2 -2
- package/dist/shared/histogram.js +4 -4
- package/package.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated HTTP route dispatcher.
|
|
3
|
+
*/
|
|
4
|
+
import { validateQueueName } from './protocol';
|
|
5
|
+
import { dashboardOverviewEndpoint, dashboardQueueDetailEndpoint, dashboardQueuesEndpoint, jsonResponse, metricsEndpoint, statsEndpoint, } from './httpEndpoints';
|
|
6
|
+
import { routeJobRoutes } from './httpRouteJobs';
|
|
7
|
+
import { routeQueueConfigRoutes } from './httpRouteQueueConfig';
|
|
8
|
+
import { routeQueueRoutes } from './httpRouteQueues';
|
|
9
|
+
import { routeResourceRoutes } from './httpRouteResources';
|
|
10
|
+
const RE_DASHBOARD_QUEUE_DETAIL = /^\/dashboard\/queues\/([^/]+)$/;
|
|
11
|
+
/** Route an authenticated HTTP request to its handler. */
|
|
12
|
+
export async function routeHttpRequest(req, path, ctx, corsOrigins) {
|
|
13
|
+
const method = req.method;
|
|
14
|
+
if (path === '/stats' && method === 'GET') {
|
|
15
|
+
return statsEndpoint(ctx.queueManager, corsOrigins);
|
|
16
|
+
}
|
|
17
|
+
if (path === '/metrics' && method === 'GET') {
|
|
18
|
+
return metricsEndpoint(ctx.queueManager, corsOrigins);
|
|
19
|
+
}
|
|
20
|
+
if (path === '/dashboard' && method === 'GET') {
|
|
21
|
+
return dashboardOverviewEndpoint(ctx.queueManager, corsOrigins);
|
|
22
|
+
}
|
|
23
|
+
if (path === '/dashboard/queues' && method === 'GET') {
|
|
24
|
+
const url = new URL(req.url);
|
|
25
|
+
const limit = Math.min(Math.max(parseInt(url.searchParams.get('limit') ?? '100', 10) || 100, 1), 500);
|
|
26
|
+
const offset = Math.max(parseInt(url.searchParams.get('offset') ?? '0', 10) || 0, 0);
|
|
27
|
+
return dashboardQueuesEndpoint(ctx.queueManager, limit, offset, corsOrigins);
|
|
28
|
+
}
|
|
29
|
+
const queueMatch = path.match(RE_DASHBOARD_QUEUE_DETAIL);
|
|
30
|
+
if (queueMatch && method === 'GET') {
|
|
31
|
+
const queue = decodeURIComponent(queueMatch[1]);
|
|
32
|
+
const queueError = validateQueueName(queue);
|
|
33
|
+
if (queueError)
|
|
34
|
+
return jsonResponse({ ok: false, error: queueError }, 400, corsOrigins);
|
|
35
|
+
const includeJobs = new URL(req.url).searchParams.get('includeJobs') === 'true';
|
|
36
|
+
return dashboardQueueDetailEndpoint(ctx.queueManager, queue, includeJobs, corsOrigins);
|
|
37
|
+
}
|
|
38
|
+
const routers = [
|
|
39
|
+
routeJobRoutes,
|
|
40
|
+
routeQueueRoutes,
|
|
41
|
+
routeQueueConfigRoutes,
|
|
42
|
+
routeResourceRoutes,
|
|
43
|
+
];
|
|
44
|
+
for (const router of routers) {
|
|
45
|
+
const result = await router(req, path, method, ctx, corsOrigins);
|
|
46
|
+
if (result)
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
return jsonResponse({ ok: false, error: 'Not found' }, 404, corsOrigins);
|
|
50
|
+
}
|
|
@@ -16,8 +16,8 @@ export declare class Histogram {
|
|
|
16
16
|
getCount(): number;
|
|
17
17
|
/** Calculate a percentile (0-100) */
|
|
18
18
|
percentile(p: number): number;
|
|
19
|
-
/** Generate Prometheus histogram lines */
|
|
20
|
-
toPrometheus(name: string, help: string): string;
|
|
19
|
+
/** Generate Prometheus histogram lines, optionally scaling observed values. */
|
|
20
|
+
toPrometheus(name: string, help: string, outputScale?: number): string;
|
|
21
21
|
/** Reset all counters */
|
|
22
22
|
reset(): void;
|
|
23
23
|
}
|
package/dist/shared/histogram.js
CHANGED
|
@@ -55,14 +55,14 @@ export class Histogram {
|
|
|
55
55
|
}
|
|
56
56
|
return this.buckets[this.buckets.length - 1];
|
|
57
57
|
}
|
|
58
|
-
/** Generate Prometheus histogram lines */
|
|
59
|
-
toPrometheus(name, help) {
|
|
58
|
+
/** Generate Prometheus histogram lines, optionally scaling observed values. */
|
|
59
|
+
toPrometheus(name, help, outputScale = 1) {
|
|
60
60
|
const lines = [`# HELP ${name} ${help}`, `# TYPE ${name} histogram`];
|
|
61
61
|
for (let i = 0; i < this.buckets.length; i++) {
|
|
62
|
-
lines.push(`${name}_bucket{le="${this.buckets[i]}"} ${this.counts[i]}`);
|
|
62
|
+
lines.push(`${name}_bucket{le="${this.buckets[i] * outputScale}"} ${this.counts[i]}`);
|
|
63
63
|
}
|
|
64
64
|
lines.push(`${name}_bucket{le="+Inf"} ${this.counts[this.buckets.length]}`);
|
|
65
|
-
lines.push(`${name}_sum ${this.sum}`);
|
|
65
|
+
lines.push(`${name}_sum ${this.sum * outputScale}`);
|
|
66
66
|
lines.push(`${name}_count ${this.count}`);
|
|
67
67
|
return lines.join('\n');
|
|
68
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunqueue",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.45",
|
|
4
4
|
"description": "High-performance job queue for Bun & AI agents. SQLite persistence, cron scheduling, priorities, retries, DLQ, webhooks, native MCP server. Zero external infrastructure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"build": "bun build --compile --minify src/main.ts --outfile dist/bunqueue",
|
|
58
58
|
"build:lib": "tsc -p tsconfig.build.json",
|
|
59
59
|
"test": "BUNQUEUE_EMBEDDED=1 bun test",
|
|
60
|
-
"test:model": "BUNQUEUE_EMBEDDED=1 bun test test/model-based/queue-model.test.ts",
|
|
60
|
+
"test:model": "BUNQUEUE_EMBEDDED=1 bun test test/model-based/queue-model.test.ts test/model-based/backup-model.test.ts test/model-based/monitoring-model.test.ts test/model-based/enterprise-telemetry-model.test.ts",
|
|
61
61
|
"test:sandbox": "bun run scripts/test-sandbox.ts",
|
|
62
62
|
"test:sandbox:sdk": "bun run scripts/test-sdk-sandbox.ts",
|
|
63
63
|
"bench": "bun run bench/throughput.ts && bun run bench/latency.ts",
|