hive-cycle 0.2.2 → 0.2.3
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/HiveCycle.js +9 -5
- package/dist/MemoryQueue.js +5 -1
- package/dist/index.js +19 -3
- package/dist/types.js +2 -1
- package/package.json +1 -1
package/dist/HiveCycle.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HiveCycle = void 0;
|
|
4
|
+
const http_1 = require("http");
|
|
5
|
+
const MemoryQueue_1 = require("./MemoryQueue");
|
|
3
6
|
// I will implement a simple ID generator to avoid deps for now if I didn't install uuid.
|
|
4
7
|
// Wait, I haven't installed `uuid`. I should probably implement a simple random ID or install it later.
|
|
5
8
|
// User didn't ask for uuid specifically, so I'll use crypto.randomUUID if available or Math.random shim.
|
|
@@ -9,13 +12,13 @@ function generateId() {
|
|
|
9
12
|
}
|
|
10
13
|
return Math.random().toString(36).substring(2, 15);
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
class HiveCycle {
|
|
13
16
|
constructor(options = {}) {
|
|
14
17
|
this.handlers = new Map();
|
|
15
18
|
this.isRunning = false;
|
|
16
19
|
this.activeCount = 0;
|
|
17
20
|
this.options = {
|
|
18
|
-
queue: options.queue || new MemoryQueue(),
|
|
21
|
+
queue: options.queue || new MemoryQueue_1.MemoryQueue(),
|
|
19
22
|
pollingInterval: options.pollingInterval || 1000,
|
|
20
23
|
maxConcurrency: options.maxConcurrency || 1,
|
|
21
24
|
logger: options.logger || console,
|
|
@@ -65,7 +68,7 @@ export class HiveCycle {
|
|
|
65
68
|
this.stopHealthServer();
|
|
66
69
|
}
|
|
67
70
|
startHealthServer(port) {
|
|
68
|
-
this.server = createServer((req, res) => {
|
|
71
|
+
this.server = (0, http_1.createServer)((req, res) => {
|
|
69
72
|
if (req.url === "/health" && req.method === "GET") {
|
|
70
73
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
71
74
|
res.end(JSON.stringify({
|
|
@@ -162,3 +165,4 @@ export class HiveCycle {
|
|
|
162
165
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
163
166
|
}
|
|
164
167
|
}
|
|
168
|
+
exports.HiveCycle = HiveCycle;
|
package/dist/MemoryQueue.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryQueue = void 0;
|
|
4
|
+
class MemoryQueue {
|
|
2
5
|
constructor() {
|
|
3
6
|
this.queue = [];
|
|
4
7
|
this.processing = new Map();
|
|
@@ -25,3 +28,4 @@ export class MemoryQueue {
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
exports.MemoryQueue = MemoryQueue;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./HiveCycle"), exports);
|
|
19
|
+
__exportStar(require("./MemoryQueue"), exports);
|
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|