@midwayjs/piscina 4.0.0-beta.11 → 4.0.0-beta.12
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/framework.js +37 -5
- package/dist/worker-bootstrap.js +0 -1
- package/package.json +4 -4
package/dist/framework.js
CHANGED
|
@@ -44,11 +44,43 @@ let PiscinaWorkerFramework = class PiscinaWorkerFramework extends core_1.BaseFra
|
|
|
44
44
|
throw new core_1.MidwayCommonError(`Task handler "${handler}" not found. Did you forget to use @PiscinaTask('${handler}') decorator?`);
|
|
45
45
|
}
|
|
46
46
|
const ctx = this.app.createAnonymousContext();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const traceService = this.applicationContext.get(core_1.MidwayTraceService);
|
|
48
|
+
const traceMetaResolver = this.configurationOptions?.tracing?.meta;
|
|
49
|
+
const traceEnabled = this.configurationOptions?.tracing?.enable !== false;
|
|
50
|
+
const traceExtractor = this.configurationOptions?.tracing
|
|
51
|
+
?.extractor;
|
|
52
|
+
const entryCarrier = typeof traceExtractor === 'function'
|
|
53
|
+
? traceExtractor({
|
|
54
|
+
ctx,
|
|
55
|
+
request: payload,
|
|
56
|
+
custom: {
|
|
57
|
+
handler,
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
: {};
|
|
61
|
+
return await traceService.runWithEntrySpan(`piscina ${handler}`, {
|
|
62
|
+
enable: traceEnabled,
|
|
63
|
+
carrier: entryCarrier,
|
|
64
|
+
attributes: {
|
|
65
|
+
'midway.protocol': 'piscina',
|
|
66
|
+
'midway.piscina.handler': handler,
|
|
67
|
+
},
|
|
68
|
+
meta: traceMetaResolver,
|
|
69
|
+
metaArgs: {
|
|
70
|
+
ctx,
|
|
71
|
+
carrier: entryCarrier,
|
|
72
|
+
request: payload,
|
|
73
|
+
custom: {
|
|
74
|
+
handler,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}, async () => {
|
|
78
|
+
const taskInstance = await ctx.requestContext.getAsync(TaskClass);
|
|
79
|
+
if (!taskInstance || typeof taskInstance.execute !== 'function') {
|
|
80
|
+
throw new core_1.MidwayCommonError(`Task "${handler}" must implement execute method`);
|
|
81
|
+
}
|
|
82
|
+
return await taskInstance.execute(payload);
|
|
83
|
+
});
|
|
52
84
|
}
|
|
53
85
|
/**
|
|
54
86
|
* 获取所有已注册的 handler
|
package/dist/worker-bootstrap.js
CHANGED
|
@@ -45,7 +45,6 @@ if (fullpath) {
|
|
|
45
45
|
// 查找 worker 目录中的 tsconfig.json
|
|
46
46
|
const workerTsConfig = path.join(baseDir, 'tsconfig.json');
|
|
47
47
|
const hasWorkerTsConfig = fs.existsSync(workerTsConfig);
|
|
48
|
-
/* eslint-disable-next-line node/no-extraneous-require */
|
|
49
48
|
require('ts-node').register(hasWorkerTsConfig
|
|
50
49
|
? { project: workerTsConfig }
|
|
51
50
|
: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/piscina",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.12",
|
|
4
4
|
"description": "Midway Component for Piscina worker thread pool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@midwayjs/core": "^4.0.0-beta.
|
|
31
|
+
"@midwayjs/core": "^4.0.0-beta.12",
|
|
32
32
|
"@midwayjs/logger": "^4.0.0",
|
|
33
|
-
"@midwayjs/mock": "^4.0.0-beta.
|
|
33
|
+
"@midwayjs/mock": "^4.0.0-beta.12"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"piscina": "5.1.4"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "1c48179b7c827ba8ec9351e9b6c36ec1726d3e11"
|
|
39
39
|
}
|