@tachybase/module-worker-thread 0.23.41 → 0.23.47
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/externalVersion.js +8 -8
- package/dist/server/workerManager.js +15 -15
- package/package.json +10 -10
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "0.23.
|
|
4
|
-
"@tachybase/schema": "0.23.
|
|
3
|
+
"@tachybase/client": "0.23.47",
|
|
4
|
+
"@tachybase/schema": "0.23.47",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/server": "0.23.
|
|
7
|
-
"@tachybase/logger": "0.23.
|
|
8
|
-
"@tachybase/module-collection": "0.23.
|
|
9
|
-
"@tachybase/module-user": "0.23.
|
|
10
|
-
"@tachybase/utils": "0.23.
|
|
11
|
-
"@tachybase/actions": "0.23.
|
|
6
|
+
"@tachybase/server": "0.23.47",
|
|
7
|
+
"@tachybase/logger": "0.23.47",
|
|
8
|
+
"@tachybase/module-collection": "0.23.47",
|
|
9
|
+
"@tachybase/module-user": "0.23.47",
|
|
10
|
+
"@tachybase/utils": "0.23.47",
|
|
11
|
+
"@tachybase/actions": "0.23.47"
|
|
12
12
|
};
|
|
@@ -48,9 +48,17 @@ function copyBasicTypes(obj) {
|
|
|
48
48
|
}
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
|
-
class
|
|
51
|
+
const _WorkerManager = class _WorkerManager {
|
|
52
52
|
constructor(app, workerNum) {
|
|
53
53
|
this.app = app;
|
|
54
|
+
this.isProd = true;
|
|
55
|
+
this.workerNum = 0;
|
|
56
|
+
this.workerList = [];
|
|
57
|
+
this.currentWorkerIndex = 0;
|
|
58
|
+
this.busyWorkers = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
this.busyWorkerSet = /* @__PURE__ */ new Set();
|
|
60
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
61
|
+
this.errorRecoveryTimes = 0;
|
|
54
62
|
if (!import_worker_threads.isMainThread) {
|
|
55
63
|
return;
|
|
56
64
|
}
|
|
@@ -62,23 +70,12 @@ class WorkerManager {
|
|
|
62
70
|
get available() {
|
|
63
71
|
return this.workerList.length > 0;
|
|
64
72
|
}
|
|
65
|
-
isProd = true;
|
|
66
|
-
workerNum = 0;
|
|
67
|
-
workerList = [];
|
|
68
|
-
currentWorkerIndex = 0;
|
|
69
|
-
busyWorkers = /* @__PURE__ */ new WeakMap();
|
|
70
|
-
busyWorkerSet = /* @__PURE__ */ new Set();
|
|
71
|
-
cache = /* @__PURE__ */ new Map();
|
|
72
|
-
errorRecoveryTimes = 0;
|
|
73
|
-
// 默认超时时间
|
|
74
|
-
static timeoutSecond = import_constants.WORKER_TIMEOUT;
|
|
75
73
|
getPluginMethodKey(values) {
|
|
76
74
|
return `worker:pluginMethod:${values.plugin}:${values.method}`;
|
|
77
75
|
}
|
|
78
76
|
getGlobalKey() {
|
|
79
77
|
return `worker:global`;
|
|
80
78
|
}
|
|
81
|
-
databaseOptions;
|
|
82
79
|
getPresetWorkerNum() {
|
|
83
80
|
return this.workerNum;
|
|
84
81
|
}
|
|
@@ -201,7 +198,7 @@ class WorkerManager {
|
|
|
201
198
|
let countInfo = cache.get(key);
|
|
202
199
|
if (countInfo && countInfo.lastTime) {
|
|
203
200
|
const diff = now - countInfo.lastTime.getTime();
|
|
204
|
-
if (diff > 1e3 *
|
|
201
|
+
if (diff > 1e3 * _WorkerManager.timeoutSecond) {
|
|
205
202
|
countInfo.count = 0;
|
|
206
203
|
this.app.logger.debug(`[worker] Reset concurrency count for ${key} due to timeout`);
|
|
207
204
|
}
|
|
@@ -357,7 +354,7 @@ class WorkerManager {
|
|
|
357
354
|
new Error("callPluginMethod timed out")
|
|
358
355
|
);
|
|
359
356
|
},
|
|
360
|
-
(values.timeoutSecond ||
|
|
357
|
+
(values.timeoutSecond || _WorkerManager.timeoutSecond) * 1e3
|
|
361
358
|
);
|
|
362
359
|
worker.on("message", handleMessage);
|
|
363
360
|
worker.on("error", handleError);
|
|
@@ -369,7 +366,10 @@ class WorkerManager {
|
|
|
369
366
|
});
|
|
370
367
|
});
|
|
371
368
|
}
|
|
372
|
-
}
|
|
369
|
+
};
|
|
370
|
+
// 默认超时时间
|
|
371
|
+
_WorkerManager.timeoutSecond = import_constants.WORKER_TIMEOUT;
|
|
372
|
+
let WorkerManager = _WorkerManager;
|
|
373
373
|
// Annotate the CommonJS export names for ESM import in node:
|
|
374
374
|
0 && (module.exports = {
|
|
375
375
|
WorkerManager
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-worker-thread",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.47",
|
|
4
4
|
"description": "Worker thread for executing time-consuming tasks",
|
|
5
5
|
"main": "dist/server/index.js",
|
|
6
6
|
"dependencies": {},
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"tsx": "^4.19.2"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@tachybase/actions": "0.23.
|
|
13
|
-
"@tachybase/client": "0.23.
|
|
14
|
-
"@tachybase/
|
|
15
|
-
"@tachybase/
|
|
16
|
-
"@tachybase/
|
|
17
|
-
"@tachybase/schema": "0.23.
|
|
18
|
-
"@tachybase/test": "0.23.
|
|
19
|
-
"@tachybase/
|
|
20
|
-
"@tachybase/
|
|
12
|
+
"@tachybase/actions": "0.23.47",
|
|
13
|
+
"@tachybase/client": "0.23.47",
|
|
14
|
+
"@tachybase/logger": "0.23.47",
|
|
15
|
+
"@tachybase/module-user": "0.23.47",
|
|
16
|
+
"@tachybase/module-collection": "0.23.47",
|
|
17
|
+
"@tachybase/schema": "0.23.47",
|
|
18
|
+
"@tachybase/test": "0.23.47",
|
|
19
|
+
"@tachybase/server": "0.23.47",
|
|
20
|
+
"@tachybase/utils": "0.23.47"
|
|
21
21
|
},
|
|
22
22
|
"description.zh-CN": "工作线程,用于执行耗时任务",
|
|
23
23
|
"displayName.zh-CN": "工作线程",
|