bunqueue 1.0.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/LICENSE +21 -0
- package/README.md +640 -0
- package/dist/application/dlqManager.d.ts +19 -0
- package/dist/application/dlqManager.d.ts.map +1 -0
- package/dist/application/dlqManager.js +44 -0
- package/dist/application/dlqManager.js.map +1 -0
- package/dist/application/eventsManager.d.ts +28 -0
- package/dist/application/eventsManager.d.ts.map +1 -0
- package/dist/application/eventsManager.js +59 -0
- package/dist/application/eventsManager.js.map +1 -0
- package/dist/application/jobLogsManager.d.ts +20 -0
- package/dist/application/jobLogsManager.d.ts.map +1 -0
- package/dist/application/jobLogsManager.js +28 -0
- package/dist/application/jobLogsManager.js.map +1 -0
- package/dist/application/metricsExporter.d.ts +24 -0
- package/dist/application/metricsExporter.d.ts.map +1 -0
- package/dist/application/metricsExporter.js +80 -0
- package/dist/application/metricsExporter.js.map +1 -0
- package/dist/application/operations/ack.d.ts +48 -0
- package/dist/application/operations/ack.d.ts.map +1 -0
- package/dist/application/operations/ack.js +109 -0
- package/dist/application/operations/ack.js.map +1 -0
- package/dist/application/operations/index.d.ts +10 -0
- package/dist/application/operations/index.d.ts.map +1 -0
- package/dist/application/operations/index.js +10 -0
- package/dist/application/operations/index.js.map +1 -0
- package/dist/application/operations/jobManagement.d.ts +32 -0
- package/dist/application/operations/jobManagement.d.ts.map +1 -0
- package/dist/application/operations/jobManagement.js +122 -0
- package/dist/application/operations/jobManagement.js.map +1 -0
- package/dist/application/operations/pull.d.ts +36 -0
- package/dist/application/operations/pull.d.ts.map +1 -0
- package/dist/application/operations/pull.js +109 -0
- package/dist/application/operations/pull.js.map +1 -0
- package/dist/application/operations/push.d.ts +36 -0
- package/dist/application/operations/push.d.ts.map +1 -0
- package/dist/application/operations/push.js +94 -0
- package/dist/application/operations/push.js.map +1 -0
- package/dist/application/operations/queryOperations.d.ts +33 -0
- package/dist/application/operations/queryOperations.d.ts.map +1 -0
- package/dist/application/operations/queryOperations.js +57 -0
- package/dist/application/operations/queryOperations.js.map +1 -0
- package/dist/application/operations/queueControl.d.ts +32 -0
- package/dist/application/operations/queueControl.d.ts.map +1 -0
- package/dist/application/operations/queueControl.js +72 -0
- package/dist/application/operations/queueControl.js.map +1 -0
- package/dist/application/queueManager.d.ts +113 -0
- package/dist/application/queueManager.d.ts.map +1 -0
- package/dist/application/queueManager.js +406 -0
- package/dist/application/queueManager.js.map +1 -0
- package/dist/application/webhookManager.d.ts +35 -0
- package/dist/application/webhookManager.d.ts.map +1 -0
- package/dist/application/webhookManager.js +109 -0
- package/dist/application/webhookManager.js.map +1 -0
- package/dist/application/workerManager.d.ts +48 -0
- package/dist/application/workerManager.d.ts.map +1 -0
- package/dist/application/workerManager.js +121 -0
- package/dist/application/workerManager.js.map +1 -0
- package/dist/domain/queue/index.d.ts +6 -0
- package/dist/domain/queue/index.d.ts.map +1 -0
- package/dist/domain/queue/index.js +6 -0
- package/dist/domain/queue/index.js.map +1 -0
- package/dist/domain/queue/priorityQueue.d.ts +45 -0
- package/dist/domain/queue/priorityQueue.d.ts.map +1 -0
- package/dist/domain/queue/priorityQueue.js +203 -0
- package/dist/domain/queue/priorityQueue.js.map +1 -0
- package/dist/domain/queue/shard.d.ts +98 -0
- package/dist/domain/queue/shard.d.ts.map +1 -0
- package/dist/domain/queue/shard.js +245 -0
- package/dist/domain/queue/shard.js.map +1 -0
- package/dist/domain/types/command.d.ts +270 -0
- package/dist/domain/types/command.d.ts.map +1 -0
- package/dist/domain/types/command.js +6 -0
- package/dist/domain/types/command.js.map +1 -0
- package/dist/domain/types/cron.d.ts +32 -0
- package/dist/domain/types/cron.d.ts.map +1 -0
- package/dist/domain/types/cron.js +31 -0
- package/dist/domain/types/cron.js.map +1 -0
- package/dist/domain/types/index.d.ts +9 -0
- package/dist/domain/types/index.d.ts.map +1 -0
- package/dist/domain/types/index.js +9 -0
- package/dist/domain/types/index.js.map +1 -0
- package/dist/domain/types/job.d.ts +94 -0
- package/dist/domain/types/job.d.ts.map +1 -0
- package/dist/domain/types/job.js +81 -0
- package/dist/domain/types/job.js.map +1 -0
- package/dist/domain/types/queue.d.ts +86 -0
- package/dist/domain/types/queue.d.ts.map +1 -0
- package/dist/domain/types/queue.js +84 -0
- package/dist/domain/types/queue.js.map +1 -0
- package/dist/domain/types/response.d.ts +158 -0
- package/dist/domain/types/response.d.ts.map +1 -0
- package/dist/domain/types/response.js +86 -0
- package/dist/domain/types/response.js.map +1 -0
- package/dist/domain/types/webhook.d.ts +33 -0
- package/dist/domain/types/webhook.d.ts.map +1 -0
- package/dist/domain/types/webhook.js +20 -0
- package/dist/domain/types/webhook.js.map +1 -0
- package/dist/domain/types/worker.d.ts +27 -0
- package/dist/domain/types/worker.d.ts.map +1 -0
- package/dist/domain/types/worker.js +27 -0
- package/dist/domain/types/worker.js.map +1 -0
- package/dist/infrastructure/persistence/index.d.ts +6 -0
- package/dist/infrastructure/persistence/index.d.ts.map +1 -0
- package/dist/infrastructure/persistence/index.js +6 -0
- package/dist/infrastructure/persistence/index.js.map +1 -0
- package/dist/infrastructure/persistence/schema.d.ts +14 -0
- package/dist/infrastructure/persistence/schema.d.ts.map +1 -0
- package/dist/infrastructure/persistence/schema.js +123 -0
- package/dist/infrastructure/persistence/schema.js.map +1 -0
- package/dist/infrastructure/persistence/sqlite.d.ts +42 -0
- package/dist/infrastructure/persistence/sqlite.d.ts.map +1 -0
- package/dist/infrastructure/persistence/sqlite.js +164 -0
- package/dist/infrastructure/persistence/sqlite.js.map +1 -0
- package/dist/infrastructure/persistence/statements.d.ts +55 -0
- package/dist/infrastructure/persistence/statements.d.ts.map +1 -0
- package/dist/infrastructure/persistence/statements.js +42 -0
- package/dist/infrastructure/persistence/statements.js.map +1 -0
- package/dist/infrastructure/scheduler/cronParser.d.ts +44 -0
- package/dist/infrastructure/scheduler/cronParser.d.ts.map +1 -0
- package/dist/infrastructure/scheduler/cronParser.js +90 -0
- package/dist/infrastructure/scheduler/cronParser.js.map +1 -0
- package/dist/infrastructure/scheduler/cronScheduler.d.ts +68 -0
- package/dist/infrastructure/scheduler/cronScheduler.d.ts.map +1 -0
- package/dist/infrastructure/scheduler/cronScheduler.js +172 -0
- package/dist/infrastructure/scheduler/cronScheduler.js.map +1 -0
- package/dist/infrastructure/scheduler/index.d.ts +6 -0
- package/dist/infrastructure/scheduler/index.d.ts.map +1 -0
- package/dist/infrastructure/scheduler/index.js +6 -0
- package/dist/infrastructure/scheduler/index.js.map +1 -0
- package/dist/infrastructure/server/handler.d.ts +13 -0
- package/dist/infrastructure/server/handler.d.ts.map +1 -0
- package/dist/infrastructure/server/handler.js +167 -0
- package/dist/infrastructure/server/handler.js.map +1 -0
- package/dist/infrastructure/server/handlers/advanced.d.ts +68 -0
- package/dist/infrastructure/server/handlers/advanced.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/advanced.js +99 -0
- package/dist/infrastructure/server/handlers/advanced.js.map +1 -0
- package/dist/infrastructure/server/handlers/core.d.ts +36 -0
- package/dist/infrastructure/server/handlers/core.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/core.js +82 -0
- package/dist/infrastructure/server/handlers/core.js.map +1 -0
- package/dist/infrastructure/server/handlers/cron.d.ts +20 -0
- package/dist/infrastructure/server/handlers/cron.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/cron.js +56 -0
- package/dist/infrastructure/server/handlers/cron.js.map +1 -0
- package/dist/infrastructure/server/handlers/dlq.d.ts +20 -0
- package/dist/infrastructure/server/handlers/dlq.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/dlq.js +31 -0
- package/dist/infrastructure/server/handlers/dlq.js.map +1 -0
- package/dist/infrastructure/server/handlers/index.d.ts +7 -0
- package/dist/infrastructure/server/handlers/index.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/index.js +7 -0
- package/dist/infrastructure/server/handlers/index.js.map +1 -0
- package/dist/infrastructure/server/handlers/management.d.ts +36 -0
- package/dist/infrastructure/server/handlers/management.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/management.js +75 -0
- package/dist/infrastructure/server/handlers/management.js.map +1 -0
- package/dist/infrastructure/server/handlers/monitoring.d.ts +18 -0
- package/dist/infrastructure/server/handlers/monitoring.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/monitoring.js +102 -0
- package/dist/infrastructure/server/handlers/monitoring.js.map +1 -0
- package/dist/infrastructure/server/handlers/query.d.ts +32 -0
- package/dist/infrastructure/server/handlers/query.d.ts.map +1 -0
- package/dist/infrastructure/server/handlers/query.js +61 -0
- package/dist/infrastructure/server/handlers/query.js.map +1 -0
- package/dist/infrastructure/server/http.d.ts +43 -0
- package/dist/infrastructure/server/http.d.ts.map +1 -0
- package/dist/infrastructure/server/http.js +344 -0
- package/dist/infrastructure/server/http.js.map +1 -0
- package/dist/infrastructure/server/index.d.ts +8 -0
- package/dist/infrastructure/server/index.d.ts.map +1 -0
- package/dist/infrastructure/server/index.js +8 -0
- package/dist/infrastructure/server/index.js.map +1 -0
- package/dist/infrastructure/server/protocol.d.ts +44 -0
- package/dist/infrastructure/server/protocol.d.ts.map +1 -0
- package/dist/infrastructure/server/protocol.js +129 -0
- package/dist/infrastructure/server/protocol.js.map +1 -0
- package/dist/infrastructure/server/rateLimiter.d.ts +31 -0
- package/dist/infrastructure/server/rateLimiter.d.ts.map +1 -0
- package/dist/infrastructure/server/rateLimiter.js +79 -0
- package/dist/infrastructure/server/rateLimiter.js.map +1 -0
- package/dist/infrastructure/server/tcp.d.ts +36 -0
- package/dist/infrastructure/server/tcp.d.ts.map +1 -0
- package/dist/infrastructure/server/tcp.js +101 -0
- package/dist/infrastructure/server/tcp.js.map +1 -0
- package/dist/infrastructure/server/types.d.ts +11 -0
- package/dist/infrastructure/server/types.d.ts.map +1 -0
- package/dist/infrastructure/server/types.js +5 -0
- package/dist/infrastructure/server/types.js.map +1 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +111 -0
- package/dist/main.js.map +1 -0
- package/dist/shared/hash.d.ts +30 -0
- package/dist/shared/hash.d.ts.map +1 -0
- package/dist/shared/hash.js +69 -0
- package/dist/shared/hash.js.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +6 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/lock.d.ts +70 -0
- package/dist/shared/lock.d.ts.map +1 -0
- package/dist/shared/lock.js +207 -0
- package/dist/shared/lock.js.map +1 -0
- package/dist/shared/logger.d.ts +38 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +74 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/serialization.d.ts +23 -0
- package/dist/shared/serialization.d.ts.map +1 -0
- package/dist/shared/serialization.js +63 -0
- package/dist/shared/serialization.js.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Lock implementation
|
|
3
|
+
* Provides read-write locks with timeout support
|
|
4
|
+
*/
|
|
5
|
+
/** Lock timeout error */
|
|
6
|
+
export class LockTimeoutError extends Error {
|
|
7
|
+
constructor(message = 'Lock acquisition timed out') {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'LockTimeoutError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Simple async mutex lock
|
|
14
|
+
* FIFO ordering for fairness
|
|
15
|
+
*/
|
|
16
|
+
export class AsyncLock {
|
|
17
|
+
locked = false;
|
|
18
|
+
queue = [];
|
|
19
|
+
/**
|
|
20
|
+
* Acquire the lock
|
|
21
|
+
* @param timeoutMs - Maximum time to wait (default: 5000ms)
|
|
22
|
+
*/
|
|
23
|
+
async acquire(timeoutMs = 5000) {
|
|
24
|
+
const start = Date.now();
|
|
25
|
+
while (this.locked) {
|
|
26
|
+
const remaining = timeoutMs - (Date.now() - start);
|
|
27
|
+
if (remaining <= 0) {
|
|
28
|
+
throw new LockTimeoutError();
|
|
29
|
+
}
|
|
30
|
+
await new Promise((resolve) => {
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
const idx = this.queue.indexOf(resolve);
|
|
33
|
+
if (idx !== -1)
|
|
34
|
+
this.queue.splice(idx, 1);
|
|
35
|
+
resolve();
|
|
36
|
+
}, remaining);
|
|
37
|
+
this.queue.push(() => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
resolve();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
this.locked = true;
|
|
44
|
+
return {
|
|
45
|
+
release: () => {
|
|
46
|
+
this.locked = false;
|
|
47
|
+
const next = this.queue.shift();
|
|
48
|
+
if (next)
|
|
49
|
+
next();
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Check if lock is held */
|
|
54
|
+
isLocked() {
|
|
55
|
+
return this.locked;
|
|
56
|
+
}
|
|
57
|
+
/** Get queue length */
|
|
58
|
+
getQueueLength() {
|
|
59
|
+
return this.queue.length;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read-Write Lock
|
|
64
|
+
* Multiple readers OR single writer
|
|
65
|
+
* Writers have priority to prevent starvation
|
|
66
|
+
*/
|
|
67
|
+
export class RWLock {
|
|
68
|
+
readers = 0;
|
|
69
|
+
writer = false;
|
|
70
|
+
writerWaiting = 0;
|
|
71
|
+
readerQueue = [];
|
|
72
|
+
writerQueue = [];
|
|
73
|
+
/**
|
|
74
|
+
* Acquire read lock
|
|
75
|
+
* Multiple readers can hold simultaneously
|
|
76
|
+
*/
|
|
77
|
+
async acquireRead(timeoutMs = 5000) {
|
|
78
|
+
const start = Date.now();
|
|
79
|
+
// Wait if writer is active or writers are waiting (writer priority)
|
|
80
|
+
while (this.writer || this.writerWaiting > 0) {
|
|
81
|
+
const remaining = timeoutMs - (Date.now() - start);
|
|
82
|
+
if (remaining <= 0) {
|
|
83
|
+
throw new LockTimeoutError('Read lock acquisition timed out');
|
|
84
|
+
}
|
|
85
|
+
await new Promise((resolve) => {
|
|
86
|
+
const timer = setTimeout(() => {
|
|
87
|
+
const idx = this.readerQueue.indexOf(resolve);
|
|
88
|
+
if (idx !== -1)
|
|
89
|
+
this.readerQueue.splice(idx, 1);
|
|
90
|
+
resolve();
|
|
91
|
+
}, remaining);
|
|
92
|
+
this.readerQueue.push(() => {
|
|
93
|
+
clearTimeout(timer);
|
|
94
|
+
resolve();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
this.readers++;
|
|
99
|
+
return {
|
|
100
|
+
release: () => {
|
|
101
|
+
this.readers--;
|
|
102
|
+
if (this.readers === 0 && this.writerWaiting > 0) {
|
|
103
|
+
const next = this.writerQueue.shift();
|
|
104
|
+
if (next)
|
|
105
|
+
next();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Acquire write lock
|
|
112
|
+
* Exclusive access, no readers or other writers
|
|
113
|
+
*/
|
|
114
|
+
async acquireWrite(timeoutMs = 5000) {
|
|
115
|
+
const start = Date.now();
|
|
116
|
+
this.writerWaiting++;
|
|
117
|
+
try {
|
|
118
|
+
while (this.writer || this.readers > 0) {
|
|
119
|
+
const remaining = timeoutMs - (Date.now() - start);
|
|
120
|
+
if (remaining <= 0) {
|
|
121
|
+
throw new LockTimeoutError('Write lock acquisition timed out');
|
|
122
|
+
}
|
|
123
|
+
await new Promise((resolve) => {
|
|
124
|
+
const timer = setTimeout(() => {
|
|
125
|
+
const idx = this.writerQueue.indexOf(resolve);
|
|
126
|
+
if (idx !== -1)
|
|
127
|
+
this.writerQueue.splice(idx, 1);
|
|
128
|
+
resolve();
|
|
129
|
+
}, remaining);
|
|
130
|
+
this.writerQueue.push(() => {
|
|
131
|
+
clearTimeout(timer);
|
|
132
|
+
resolve();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
this.writerWaiting--;
|
|
137
|
+
this.writer = true;
|
|
138
|
+
return {
|
|
139
|
+
release: () => {
|
|
140
|
+
this.writer = false;
|
|
141
|
+
// Notify waiting writers first (priority)
|
|
142
|
+
if (this.writerWaiting > 0) {
|
|
143
|
+
const next = this.writerQueue.shift();
|
|
144
|
+
if (next)
|
|
145
|
+
next();
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Then notify all waiting readers
|
|
149
|
+
const readers = this.readerQueue.splice(0);
|
|
150
|
+
for (const reader of readers) {
|
|
151
|
+
reader();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
this.writerWaiting--;
|
|
159
|
+
throw e;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Get current state */
|
|
163
|
+
getState() {
|
|
164
|
+
return {
|
|
165
|
+
readers: this.readers,
|
|
166
|
+
writer: this.writer,
|
|
167
|
+
writerWaiting: this.writerWaiting,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Execute with lock, ensuring release on error
|
|
173
|
+
*/
|
|
174
|
+
export async function withLock(lock, fn, timeoutMs) {
|
|
175
|
+
const guard = await lock.acquire(timeoutMs);
|
|
176
|
+
try {
|
|
177
|
+
return await fn();
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
guard.release();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Execute with read lock
|
|
185
|
+
*/
|
|
186
|
+
export async function withReadLock(lock, fn, timeoutMs) {
|
|
187
|
+
const guard = await lock.acquireRead(timeoutMs);
|
|
188
|
+
try {
|
|
189
|
+
return await fn();
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
guard.release();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Execute with write lock
|
|
197
|
+
*/
|
|
198
|
+
export async function withWriteLock(lock, fn, timeoutMs) {
|
|
199
|
+
const guard = await lock.acquireWrite(timeoutMs);
|
|
200
|
+
try {
|
|
201
|
+
return await fn();
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
guard.release();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/shared/lock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,yBAAyB;AACzB,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,UAAkB,4BAA4B;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,GAAG,KAAK,CAAC;IACN,KAAK,GAAsB,EAAE,CAAC;IAE/C;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,YAAoB,IAAI;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,SAAS,GAAG,SAAS,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;YACnD,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;gBACnB,MAAM,IAAI,gBAAgB,EAAE,CAAC;YAC/B,CAAC;YAED,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBACxC,IAAI,GAAG,KAAK,CAAC,CAAC;wBAAE,IAAI,CAAC,KAAK,CA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AE,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
* JSON-formatted logging for production environments
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
6
|
+
export interface LogEntry {
|
|
7
|
+
timestamp: string;
|
|
8
|
+
level: LogLevel;
|
|
9
|
+
component: string;
|
|
10
|
+
message: string;
|
|
11
|
+
reqId?: string;
|
|
12
|
+
data?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Logger class for structured logging */
|
|
15
|
+
export declare class Logger {
|
|
16
|
+
private readonly component;
|
|
17
|
+
private static jsonMode;
|
|
18
|
+
constructor(component: string);
|
|
19
|
+
/** Enable JSON output mode */
|
|
20
|
+
static enableJsonMode(): void;
|
|
21
|
+
/** Disable JSON output mode (use human-readable) */
|
|
22
|
+
static disableJsonMode(): void;
|
|
23
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
24
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
25
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
26
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
27
|
+
private log;
|
|
28
|
+
}
|
|
29
|
+
/** Create a logger for a component */
|
|
30
|
+
export declare function createLogger(component: string): Logger;
|
|
31
|
+
/** Global loggers */
|
|
32
|
+
export declare const serverLog: Logger;
|
|
33
|
+
export declare const tcpLog: Logger;
|
|
34
|
+
export declare const httpLog: Logger;
|
|
35
|
+
export declare const wsLog: Logger;
|
|
36
|
+
export declare const cronLog: Logger;
|
|
37
|
+
export declare const statsLog: Logger;
|
|
38
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/shared/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OA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O,MAAM,KAAK,QAAqB,CAAC;AACxC,eAAO,MAAM,OAAO,QAAuB,CAAC;AAC5C,eAAO,MAAM,QAAQ,QAAwB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
* JSON-formatted logging for production environments
|
|
4
|
+
*/
|
|
5
|
+
/** Logger class for structured logging */
|
|
6
|
+
export class Logger {
|
|
7
|
+
component;
|
|
8
|
+
static jsonMode = false;
|
|
9
|
+
constructor(component) {
|
|
10
|
+
this.component = component;
|
|
11
|
+
}
|
|
12
|
+
/** Enable JSON output mode */
|
|
13
|
+
static enableJsonMode() {
|
|
14
|
+
Logger.jsonMode = true;
|
|
15
|
+
}
|
|
16
|
+
/** Disable JSON output mode (use human-readable) */
|
|
17
|
+
static disableJsonMode() {
|
|
18
|
+
Logger.jsonMode = false;
|
|
19
|
+
}
|
|
20
|
+
debug(message, data) {
|
|
21
|
+
this.log('debug', message, data);
|
|
22
|
+
}
|
|
23
|
+
info(message, data) {
|
|
24
|
+
this.log('info', message, data);
|
|
25
|
+
}
|
|
26
|
+
warn(message, data) {
|
|
27
|
+
this.log('warn', message, data);
|
|
28
|
+
}
|
|
29
|
+
error(message, data) {
|
|
30
|
+
this.log('error', message, data);
|
|
31
|
+
}
|
|
32
|
+
log(level, message, data) {
|
|
33
|
+
if (Logger.jsonMode) {
|
|
34
|
+
const entry = {
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
level,
|
|
37
|
+
component: this.component,
|
|
38
|
+
message,
|
|
39
|
+
...(data && { data }),
|
|
40
|
+
};
|
|
41
|
+
console.log(JSON.stringify(entry));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const prefix = `[${this.component}]`;
|
|
45
|
+
const dataStr = data ? ` ${JSON.stringify(data)}` : '';
|
|
46
|
+
switch (level) {
|
|
47
|
+
case 'debug':
|
|
48
|
+
console.debug(`${prefix} ${message}${dataStr}`);
|
|
49
|
+
break;
|
|
50
|
+
case 'info':
|
|
51
|
+
console.log(`${prefix} ${message}${dataStr}`);
|
|
52
|
+
break;
|
|
53
|
+
case 'warn':
|
|
54
|
+
console.warn(`${prefix} ${message}${dataStr}`);
|
|
55
|
+
break;
|
|
56
|
+
case 'error':
|
|
57
|
+
console.error(`${prefix} ${message}${dataStr}`);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Create a logger for a component */
|
|
64
|
+
export function createLogger(component) {
|
|
65
|
+
return new Logger(component);
|
|
66
|
+
}
|
|
67
|
+
/** Global loggers */
|
|
68
|
+
export const serverLog = createLogger('Server');
|
|
69
|
+
export const tcpLog = createLogger('TCP');
|
|
70
|
+
export const httpLog = createLogger('HTTP');
|
|
71
|
+
export const wsLog = createLogger('WS');
|
|
72
|
+
export const cronLog = createLogger('Cron');
|
|
73
|
+
export const statsLog = createLogger('Stats');
|
|
74
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/shared/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,0CAA0C;AAC1C,MAAM,OAAO,MAAM;IAGY;IAFrB,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IAEhC,YAA6B,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElD,8BAA8B;IAC9B,MAAM,CAAC,cAAc;QACnB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,oDAAoD;IACpD,MAAM,CAAC,eAAe;QACpB,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAA8B;QACnD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAA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I,CAAC,GAAG,MAAM,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC;oBAC/C,MAAM;gBACR,KAAK,OAAO;oBACV,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC,CAAC;oBAChD,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;;AAGH,sCAAsC;AACtC,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialization utilities
|
|
3
|
+
* Handle BigInt and other special types for JSON serialization
|
|
4
|
+
*/
|
|
5
|
+
import type { Job } from '../domain/types/job';
|
|
6
|
+
/**
|
|
7
|
+
* Serialize a Job for JSON output
|
|
8
|
+
* Converts BigInt IDs to strings
|
|
9
|
+
*/
|
|
10
|
+
export declare function serializeJob(job: Job): Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Serialize multiple jobs
|
|
13
|
+
*/
|
|
14
|
+
export declare function serializeJobs(jobs: Job[]): Record<string, unknown>[];
|
|
15
|
+
/**
|
|
16
|
+
* Custom JSON replacer for BigInt
|
|
17
|
+
*/
|
|
18
|
+
export declare function bigIntReplacer(_key: string, value: unknown): unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Stringify with BigInt support
|
|
21
|
+
*/
|
|
22
|
+
export declare function jsonStringify(value: unknown): string;
|
|
23
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/shared/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgC9D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAEpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAKpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialization utilities
|
|
3
|
+
* Handle BigInt and other special types for JSON serialization
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Serialize a Job for JSON output
|
|
7
|
+
* Converts BigInt IDs to strings
|
|
8
|
+
*/
|
|
9
|
+
export function serializeJob(job) {
|
|
10
|
+
return {
|
|
11
|
+
id: job.id.toString(),
|
|
12
|
+
queue: job.queue,
|
|
13
|
+
data: job.data,
|
|
14
|
+
priority: job.priority,
|
|
15
|
+
createdAt: job.createdAt,
|
|
16
|
+
runAt: job.runAt,
|
|
17
|
+
startedAt: job.startedAt,
|
|
18
|
+
completedAt: job.completedAt,
|
|
19
|
+
attempts: job.attempts,
|
|
20
|
+
maxAttempts: job.maxAttempts,
|
|
21
|
+
backoff: job.backoff,
|
|
22
|
+
ttl: job.ttl,
|
|
23
|
+
timeout: job.timeout,
|
|
24
|
+
uniqueKey: job.uniqueKey,
|
|
25
|
+
customId: job.customId,
|
|
26
|
+
dependsOn: job.dependsOn.map((id) => id.toString()),
|
|
27
|
+
parentId: job.parentId?.toString() ?? null,
|
|
28
|
+
childrenIds: job.childrenIds.map((id) => id.toString()),
|
|
29
|
+
childrenCompleted: job.childrenCompleted,
|
|
30
|
+
tags: job.tags,
|
|
31
|
+
groupId: job.groupId,
|
|
32
|
+
progress: job.progress,
|
|
33
|
+
progressMessage: job.progressMessage,
|
|
34
|
+
removeOnComplete: job.removeOnComplete,
|
|
35
|
+
removeOnFail: job.removeOnFail,
|
|
36
|
+
lastHeartbeat: job.lastHeartbeat,
|
|
37
|
+
stallTimeout: job.stallTimeout,
|
|
38
|
+
stallCount: job.stallCount,
|
|
39
|
+
lifo: job.lifo,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Serialize multiple jobs
|
|
44
|
+
*/
|
|
45
|
+
export function serializeJobs(jobs) {
|
|
46
|
+
return jobs.map(serializeJob);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Custom JSON replacer for BigInt
|
|
50
|
+
*/
|
|
51
|
+
export function bigIntReplacer(_key, value) {
|
|
52
|
+
if (typeof value === 'bigint') {
|
|
53
|
+
return value.toString();
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stringify with BigInt support
|
|
59
|
+
*/
|
|
60
|
+
export function jsonStringify(value) {
|
|
61
|
+
return JSON.stringify(value, bigIntReplacer);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/shared/serialization.ts"],"names":[],"mappings":"AAAA;;;GAG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Aa;QAChC,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,IAAI,EAAE,GAAG,CAAC,IAAI;KACf,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAW;IACvC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAc;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC/C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bunqueue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "High-performance job queue server for Bun. SQLite persistence, cron jobs, priorities, DLQ. Zero external dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"types": "dist/main.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"bunqueue": "./dist/main.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/main.d.ts",
|
|
14
|
+
"import": "./dist/main.js"
|
|
15
|
+
},
|
|
16
|
+
"./queue": {
|
|
17
|
+
"types": "./dist/application/queueManager.d.ts",
|
|
18
|
+
"import": "./dist/application/queueManager.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"prepare": "git config core.hooksPath .husky",
|
|
28
|
+
"dev": "bun run --watch src/main.ts",
|
|
29
|
+
"start": "bun run src/main.ts",
|
|
30
|
+
"build": "bun build --compile --minify src/main.ts --outfile dist/bunqueue",
|
|
31
|
+
"build:lib": "tsc -p tsconfig.build.json",
|
|
32
|
+
"test": "bun test",
|
|
33
|
+
"bench": "bun run benchmarks/index.ts",
|
|
34
|
+
"lint": "eslint src/",
|
|
35
|
+
"lint:fix": "eslint src/ --fix",
|
|
36
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
37
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"check": "bun run typecheck && bun run lint && bun run format:check",
|
|
40
|
+
"prepublishOnly": "bun run build:lib"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"croner": "^9.0.0",
|
|
44
|
+
"@msgpack/msgpack": "^3.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/bun": "latest",
|
|
48
|
+
"typescript": "^5.7.3",
|
|
49
|
+
"@eslint/js": "^9.18.0",
|
|
50
|
+
"typescript-eslint": "^8.21.0",
|
|
51
|
+
"eslint": "^9.18.0",
|
|
52
|
+
"eslint-config-prettier": "^10.0.1",
|
|
53
|
+
"prettier": "^3.4.2"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"bun": ">=1.0.0"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"job-queue",
|
|
60
|
+
"task-queue",
|
|
61
|
+
"background-jobs",
|
|
62
|
+
"bun",
|
|
63
|
+
"sqlite",
|
|
64
|
+
"cron",
|
|
65
|
+
"worker",
|
|
66
|
+
"queue"
|
|
67
|
+
],
|
|
68
|
+
"author": "egeominotti",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "git+https://github.com/egeominotti/bunQ.git"
|
|
73
|
+
},
|
|
74
|
+
"bugs": {
|
|
75
|
+
"url": "https://github.com/egeominotti/bunQ/issues"
|
|
76
|
+
},
|
|
77
|
+
"homepage": "https://github.com/egeominotti/bunQ#readme",
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=18.0.0",
|
|
80
|
+
"bun": ">=1.0.0"
|
|
81
|
+
}
|
|
82
|
+
}
|