bunqueue 2.8.56 → 2.8.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunqueue",
3
- "version": "2.8.56",
3
+ "version": "2.8.57",
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",
@@ -1,148 +0,0 @@
1
- /**
2
- * Shared types for QueueManager modules
3
- */
4
- import type { Job, JobId, JobLock } from '../domain/types/job';
5
- import type { JobLocation } from '../domain/types/queue';
6
- import type { JobLogEntry } from '../domain/types/worker';
7
- import type { Shard } from '../domain/queue/shard';
8
- import type { SqliteStorage } from '../infrastructure/persistence/sqlite';
9
- import type { RWLock } from '../shared/lock';
10
- import type { LRUMap, BoundedSet, BoundedMap, SetLike, MapLike } from '../shared/lru';
11
- import type { EventsManager } from './eventsManager';
12
- import type { WebhookManager } from './webhookManager';
13
- import type { WorkerManager } from './workerManager';
14
- import type { MonitoringState } from './monitoringChecks';
15
- import type { DependencyResultTracker } from './dependencyResultTracker';
16
- import type { DependencyCompletionTracker } from './dependencyCompletions';
17
- /** Queue Manager configuration */
18
- export interface QueueManagerConfig {
19
- dataPath?: string;
20
- maxCompletedJobs?: number;
21
- maxJobResults?: number;
22
- maxJobLogs?: number;
23
- maxCustomIds?: number;
24
- maxWaitingDeps?: number;
25
- /** Maximum queue label values emitted in one Prometheus scrape; zero disables them. */
26
- maxPrometheusQueues?: number;
27
- cleanupIntervalMs?: number;
28
- jobTimeoutCheckMs?: number;
29
- dependencyCheckMs?: number;
30
- stallCheckMs?: number;
31
- dlqMaintenanceMs?: number;
32
- validateWebhookUrls?: boolean;
33
- }
34
- export declare const DEFAULT_CONFIG: {
35
- maxCompletedJobs: number;
36
- maxJobResults: number;
37
- maxJobLogs: number;
38
- maxCustomIds: number;
39
- maxWaitingDeps: number;
40
- maxPrometheusQueues: number;
41
- cleanupIntervalMs: number;
42
- jobTimeoutCheckMs: number;
43
- dependencyCheckMs: number;
44
- stallCheckMs: number;
45
- dlqMaintenanceMs: number;
46
- };
47
- /** Shared state accessible by all modules */
48
- export interface QueueManagerState {
49
- readonly config: typeof DEFAULT_CONFIG & {
50
- dataPath?: string;
51
- };
52
- readonly storage: SqliteStorage | null;
53
- readonly shards: Shard[];
54
- readonly shardLocks: RWLock[];
55
- readonly processingShards: Map<JobId, Job>[];
56
- readonly processingLocks: RWLock[];
57
- readonly jobIndex: Map<JobId, JobLocation>;
58
- readonly completedJobs: BoundedSet<JobId>;
59
- readonly jobResults: LRUMap<JobId, unknown>;
60
- readonly dependencyResults: DependencyResultTracker;
61
- readonly customIdMap: LRUMap<string, JobId>;
62
- readonly jobLogs: LRUMap<JobId, JobLogEntry[]>;
63
- readonly jobLocks: Map<JobId, JobLock>;
64
- readonly clientJobs: Map<string, Set<JobId>>;
65
- readonly stalledCandidates: Set<JobId>;
66
- readonly pendingDepChecks: Set<JobId>;
67
- readonly queueNamesCache: Set<string>;
68
- readonly eventsManager: EventsManager;
69
- readonly webhookManager: WebhookManager;
70
- readonly metrics: {
71
- totalPushed: {
72
- value: bigint;
73
- };
74
- totalPulled: {
75
- value: bigint;
76
- };
77
- totalCompleted: {
78
- value: bigint;
79
- };
80
- totalFailed: {
81
- value: bigint;
82
- };
83
- };
84
- readonly startTime: number;
85
- readonly perQueueMetrics: MapLike<string, {
86
- totalCompleted: bigint;
87
- totalFailed: bigint;
88
- }>;
89
- }
90
- /** Context for lock operations */
91
- export interface LockContext {
92
- jobIndex: Map<JobId, JobLocation>;
93
- jobLocks: Map<JobId, JobLock>;
94
- clientJobs: Map<string, Set<JobId>>;
95
- processingShards: Map<JobId, Job>[];
96
- processingLocks: RWLock[];
97
- shards: Shard[];
98
- shardLocks: RWLock[];
99
- eventsManager: EventsManager;
100
- dashboardEmit?: (event: string, data: Record<string, unknown>) => void;
101
- storage: SqliteStorage | null;
102
- }
103
- /** Context for background tasks */
104
- export interface BackgroundContext extends QueueManagerState {
105
- fail: (jobId: JobId, error?: string) => Promise<void>;
106
- registerQueueName: (queue: string) => void;
107
- unregisterQueueName: (queue: string) => void;
108
- dashboardEmit?: (event: string, data: Record<string, unknown>) => void;
109
- workerManager: WorkerManager;
110
- monitoringState: MonitoringState;
111
- completedJobsData: BoundedMap<JobId, Job>;
112
- depCompletions?: DependencyCompletionTracker;
113
- maxDependencyCompletions: number;
114
- timedOutJobs?: BoundedSet<JobId>;
115
- }
116
- /** Context for stats operations */
117
- export interface StatsContext {
118
- shards: Shard[];
119
- processingShards: Map<JobId, Job>[];
120
- completedJobs: SetLike<JobId>;
121
- jobIndex: Map<JobId, JobLocation>;
122
- jobResults: LRUMap<JobId, unknown>;
123
- jobLogs: LRUMap<JobId, JobLogEntry[]>;
124
- customIdMap: LRUMap<string, JobId>;
125
- jobLocks: Map<JobId, JobLock>;
126
- clientJobs: Map<string, Set<JobId>>;
127
- pendingDepChecks: Set<JobId>;
128
- stalledCandidates: Set<JobId>;
129
- metrics: {
130
- totalPushed: {
131
- value: bigint;
132
- };
133
- totalPulled: {
134
- value: bigint;
135
- };
136
- totalCompleted: {
137
- value: bigint;
138
- };
139
- totalFailed: {
140
- value: bigint;
141
- };
142
- };
143
- startTime: number;
144
- perQueueMetrics?: MapLike<string, {
145
- totalCompleted: bigint;
146
- totalFailed: bigint;
147
- }>;
148
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Shared types for QueueManager modules
3
- */
4
- export const DEFAULT_CONFIG = {
5
- maxCompletedJobs: 50_000,
6
- maxJobResults: 10_000,
7
- maxJobLogs: 10_000,
8
- maxCustomIds: 50_000,
9
- maxWaitingDeps: 10_000,
10
- maxPrometheusQueues: 100,
11
- cleanupIntervalMs: 10_000,
12
- jobTimeoutCheckMs: 5_000,
13
- dependencyCheckMs: 30_000, // Safety fallback only; event-driven handles fast path
14
- stallCheckMs: 5_000,
15
- dlqMaintenanceMs: 60_000,
16
- };
@@ -1,33 +0,0 @@
1
- /**
2
- * Queue Internal Types
3
- * Shared types for queue module operations
4
- */
5
- import type { TcpConnectionPool } from '../tcpPool';
6
- import type { QueueOptions, JobStateType } from '../types';
7
- /** Internal queue context for operations */
8
- export interface QueueContext {
9
- name: string;
10
- opts: QueueOptions;
11
- embedded: boolean;
12
- tcp: TcpConnectionPool | null;
13
- getJobState: (id: string) => Promise<JobStateType>;
14
- removeAsync: (id: string) => Promise<void>;
15
- retryJob: (id: string) => Promise<void>;
16
- getChildrenValues: (id: string) => Promise<Record<string, unknown>>;
17
- }
18
- /** Job creation context for proxy */
19
- export interface JobCreationContext {
20
- queueName: string;
21
- tcp: TcpConnectionPool | null;
22
- getJobState: (id: string) => Promise<string>;
23
- removeAsync: (id: string) => Promise<void>;
24
- retryJob: (id: string) => Promise<void>;
25
- getChildrenValues: (id: string) => Promise<Record<string, unknown>>;
26
- }
27
- /** TCP response with optional data */
28
- export interface TcpResponse {
29
- ok: boolean;
30
- error?: string;
31
- data?: unknown;
32
- [key: string]: unknown;
33
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Queue Internal Types
3
- * Shared types for queue module operations
4
- */
5
- export {};
@@ -1,79 +0,0 @@
1
- /**
2
- * Sandboxed Worker Types
3
- * Type definitions for sandboxed worker processes
4
- */
5
- import type { SharedManager } from '../manager';
6
- import type { ConnectionOptions } from '../types';
7
- import type { Job as DomainJob } from '../../domain/types/job';
8
- /** Sandboxed worker configuration */
9
- export interface SandboxedWorkerOptions {
10
- /** Path to processor file (must export default async function) */
11
- processor: string;
12
- /** Number of worker processes (default: 1) */
13
- concurrency?: number;
14
- /** Max memory per worker in MB - uses smol mode if <= 64 (default: 256) */
15
- maxMemory?: number;
16
- /** Job timeout in ms (default: 30000) */
17
- timeout?: number;
18
- /** Auto-restart crashed workers (default: true) */
19
- autoRestart?: boolean;
20
- /** Max restarts before giving up (default: 10) */
21
- maxRestarts?: number;
22
- /** Poll interval when no workers are idle (default: 10ms) */
23
- pollInterval?: number;
24
- /** Custom QueueManager (for testing, defaults to shared manager) */
25
- manager?: SharedManager;
26
- /** TCP connection options (if provided, uses TCP mode instead of embedded) */
27
- connection?: ConnectionOptions;
28
- /** Heartbeat interval in ms for TCP lock renewal (default: 10000 for TCP, 0 for embedded) */
29
- heartbeatInterval?: number;
30
- /** Auto-stop after this many ms of inactivity (0 = disabled, default: 0) */
31
- idleTimeout?: number;
32
- /** Recycle individual idle worker processes after this many ms (default: 30000, 0 = disabled) */
33
- idleRecycleMs?: number;
34
- /** Auto-restart worker pool when new jobs arrive after idle shutdown (default: false) */
35
- autoStart?: boolean;
36
- /** Poll interval in ms for checking new jobs while in idle-shutdown state (default: 5000) */
37
- autoStartPollMs?: number;
38
- }
39
- /** Required options with defaults applied */
40
- export interface RequiredSandboxedWorkerOptions {
41
- processor: string;
42
- concurrency: number;
43
- maxMemory: number;
44
- timeout: number;
45
- autoRestart: boolean;
46
- maxRestarts: number;
47
- pollInterval: number;
48
- }
49
- /** Worker process state */
50
- export interface WorkerProcess {
51
- worker: Worker;
52
- busy: boolean;
53
- currentJob: DomainJob | null;
54
- currentToken: string | null;
55
- restarts: number;
56
- timeoutId: Timer | null;
57
- lastIdleAt: number;
58
- terminated: boolean;
59
- }
60
- /** IPC message from main to worker */
61
- export interface IPCRequest {
62
- type: 'job';
63
- job: {
64
- id: string;
65
- data: unknown;
66
- queue: string;
67
- attempts: number;
68
- parentId?: string;
69
- };
70
- }
71
- /** IPC message from worker to main */
72
- export interface IPCResponse {
73
- type: 'result' | 'error' | 'progress' | 'log' | 'fail' | 'ready';
74
- jobId?: string;
75
- result?: unknown;
76
- error?: string;
77
- progress?: number;
78
- message?: string;
79
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Sandboxed Worker Types
3
- * Type definitions for sandboxed worker processes
4
- */
5
- export {};
@@ -1,50 +0,0 @@
1
- /**
2
- * Worker Types
3
- * Type definitions for worker module
4
- */
5
- import type { ConnectionOptions } from '../types';
6
- /** Pending ACK item with result and optional lock token */
7
- export interface PendingAck {
8
- id: string;
9
- result: unknown;
10
- token?: string;
11
- resolve: () => void;
12
- reject: (err: Error) => void;
13
- }
14
- /** Extended options with all defaults */
15
- export interface ExtendedWorkerOptions {
16
- concurrency: number;
17
- autorun: boolean;
18
- heartbeatInterval: number;
19
- batchSize: number;
20
- pollTimeout: number;
21
- embedded: boolean;
22
- useLocks: boolean;
23
- skipLockRenewal: boolean;
24
- skipStalledCheck: boolean;
25
- drainDelay: number;
26
- lockDuration: number;
27
- maxStalledCount: number;
28
- removeOnComplete?: boolean | number | {
29
- age?: number;
30
- count?: number;
31
- };
32
- removeOnFail?: boolean | number | {
33
- age?: number;
34
- count?: number;
35
- };
36
- connection?: ConnectionOptions;
37
- }
38
- /** TCP connection interface */
39
- export interface TcpConnection {
40
- send: (cmd: Record<string, unknown>) => Promise<Record<string, unknown>>;
41
- }
42
- /** Check if embedded mode should be forced (for tests) */
43
- export declare const FORCE_EMBEDDED: boolean;
44
- /** Worker constants */
45
- export declare const WORKER_CONSTANTS: {
46
- readonly MAX_BACKOFF_MS: 30000;
47
- readonly BASE_BACKOFF_MS: 100;
48
- readonly MAX_POLL_TIMEOUT: 30000;
49
- readonly DEFAULT_ACK_INTERVAL: 50;
50
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * Worker Types
3
- * Type definitions for worker module
4
- */
5
- /** Check if embedded mode should be forced (for tests) */
6
- export const FORCE_EMBEDDED = Bun.env.BUNQUEUE_EMBEDDED === '1';
7
- /** Worker constants */
8
- export const WORKER_CONSTANTS = {
9
- MAX_BACKOFF_MS: 30_000,
10
- BASE_BACKOFF_MS: 100,
11
- MAX_POLL_TIMEOUT: 30_000,
12
- DEFAULT_ACK_INTERVAL: 50,
13
- };