@joystick.js/node-canary 0.0.0-canary.343 → 0.0.0-canary.345
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.
|
@@ -63,20 +63,20 @@ var queues_default = {
|
|
|
63
63
|
}
|
|
64
64
|
const db = this.db?.collection(`queue_${this.queue.name}`);
|
|
65
65
|
const indexes = await db?.indexes();
|
|
66
|
-
db.createIndex({ status: 1 });
|
|
67
|
-
db.createIndex({ status: 1, nextRunAt: 1 });
|
|
68
|
-
db.createIndex({ status: 1, environment: 1, nextRunAt: 1, lockedBy: 1 });
|
|
66
|
+
await db.createIndex({ status: 1 });
|
|
67
|
+
await db.createIndex({ status: 1, nextRunAt: 1 });
|
|
68
|
+
await db.createIndex({ status: 1, environment: 1, nextRunAt: 1, lockedBy: 1 });
|
|
69
69
|
if (this.queue.options?.cleanup?.completedAfterSeconds) {
|
|
70
70
|
if (indexes?.find((index) => index?.name === "completedAt_1")) {
|
|
71
71
|
await db.dropIndex({ completedAt: 1 });
|
|
72
72
|
}
|
|
73
|
-
db.createIndex({ completedAt: 1 }, { expireAfterSeconds: this?.queue?.options?.cleanup?.completedAfterSeconds });
|
|
73
|
+
await db.createIndex({ completedAt: 1 }, { expireAfterSeconds: this?.queue?.options?.cleanup?.completedAfterSeconds });
|
|
74
74
|
}
|
|
75
75
|
if (this.queue.options?.cleanup?.failedAfterSeconds) {
|
|
76
76
|
if (indexes?.find((index) => index?.name === "failedAt_1")) {
|
|
77
77
|
await db.dropIndex({ failedAt: 1 });
|
|
78
78
|
}
|
|
79
|
-
db.createIndex({ failedAt: 1 }, { expireAfterSeconds: this?.queue?.options?.cleanup?.failedAfterSeconds });
|
|
79
|
+
await db.createIndex({ failedAt: 1 }, { expireAfterSeconds: this?.queue?.options?.cleanup?.failedAfterSeconds });
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
logAttempt: function(jobId = "") {
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const KILOBYTE = 1e3;
|
|
2
|
+
const MEGABYTE = KILOBYTE * 1e3;
|
|
1
3
|
const HTML_ENTITY_MAP = {
|
|
2
4
|
"&": "&",
|
|
3
5
|
"<": "<",
|
|
@@ -9,5 +11,7 @@ const HTML_ENTITY_MAP = {
|
|
|
9
11
|
"=": "="
|
|
10
12
|
};
|
|
11
13
|
export {
|
|
12
|
-
HTML_ENTITY_MAP
|
|
14
|
+
HTML_ENTITY_MAP,
|
|
15
|
+
KILOBYTE,
|
|
16
|
+
MEGABYTE
|
|
13
17
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MongoClient } from "mongodb";
|
|
2
|
+
import { MEGABYTE } from "../lib/constants.js";
|
|
3
|
+
const connectMongoDB = async () => {
|
|
4
|
+
const client = new MongoClient("mongodb://localhost:27017");
|
|
5
|
+
const db = client.db("push");
|
|
6
|
+
await db.collection("logs").drop();
|
|
7
|
+
await db.collection("metrics").drop();
|
|
8
|
+
await db.createCollection("logs", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
9
|
+
await db.createCollection("metrics", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
10
|
+
await db.collection("logs").createIndex({ timestamp: 1 });
|
|
11
|
+
await db.collection("metrics").createIndex({ timestamp: 1 });
|
|
12
|
+
await client.connect();
|
|
13
|
+
return {
|
|
14
|
+
client,
|
|
15
|
+
db
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
var connectMongoDB_default = connectMongoDB;
|
|
19
|
+
export {
|
|
20
|
+
connectMongoDB_default as default
|
|
21
|
+
};
|
package/dist/push/logs/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { MongoClient } from "mongodb";
|
|
2
1
|
import timestamps from "../../lib/timestamps";
|
|
3
|
-
|
|
4
|
-
const MEGABYTE = KILOBYTE * 1e3;
|
|
2
|
+
import connectMongoDB from "../connectMongoDB.js";
|
|
5
3
|
const captureLog = (callback = null) => {
|
|
6
4
|
process.stdout.write = (data) => {
|
|
7
5
|
if (callback) {
|
|
@@ -24,22 +22,8 @@ const captureLog = (callback = null) => {
|
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const db = client.db("push");
|
|
30
|
-
try {
|
|
31
|
-
await db.createCollection("logs", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
32
|
-
await db.createCollection("metrics", { capped: true, size: MEGABYTE * 50, max: 1e3 });
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
await client.connect();
|
|
36
|
-
return {
|
|
37
|
-
client,
|
|
38
|
-
db
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
const writeLogsToDisk = () => {
|
|
42
|
-
captureLog(async (source = "", data = "") => {
|
|
25
|
+
var logs_default = () => {
|
|
26
|
+
return captureLog(async (source = "", data = "") => {
|
|
43
27
|
const mongodb = await connectMongoDB();
|
|
44
28
|
switch (source) {
|
|
45
29
|
case "stdout":
|
|
@@ -65,9 +49,6 @@ const writeLogsToDisk = () => {
|
|
|
65
49
|
}
|
|
66
50
|
});
|
|
67
51
|
};
|
|
68
|
-
var logs_default = () => {
|
|
69
|
-
return writeLogsToDisk();
|
|
70
|
-
};
|
|
71
52
|
export {
|
|
72
53
|
logs_default as default
|
|
73
54
|
};
|
package/dist/websockets/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var websockets_default = (serverName = "") => {
|
|
|
4
4
|
return {
|
|
5
5
|
send: (payload = {}, uniqueConnectionId = "") => {
|
|
6
6
|
const emitterName = uniqueConnectionId ? `${serverName}_${uniqueConnectionId}` : serverName;
|
|
7
|
+
emitWebsocketEvent(emitterName, "message", payload);
|
|
7
8
|
trackFunctionCall(`node.websockets.${serverName}.send`, [
|
|
8
9
|
payload
|
|
9
10
|
]);
|
|
10
|
-
emitWebsocketEvent(emitterName, "message", payload);
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
};
|