@midwayjs/one-shot 4.0.0-beta.10 → 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 +40 -8
- package/package.json +4 -4
package/dist/framework.js
CHANGED
|
@@ -31,14 +31,46 @@ let MidwayOneShotFramework = class MidwayOneShotFramework extends core_1.BaseFra
|
|
|
31
31
|
...ctxData,
|
|
32
32
|
payload,
|
|
33
33
|
});
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const traceService = this.applicationContext.get(core_1.MidwayTraceService);
|
|
35
|
+
const traceMetaResolver = this.configurationOptions?.tracing?.meta;
|
|
36
|
+
const traceEnabled = this.configurationOptions?.tracing?.enable !== false;
|
|
37
|
+
const traceExtractor = this.configurationOptions?.tracing
|
|
38
|
+
?.extractor;
|
|
39
|
+
const entryCarrier = typeof traceExtractor === 'function'
|
|
40
|
+
? traceExtractor({
|
|
41
|
+
ctx,
|
|
42
|
+
request: payload,
|
|
43
|
+
custom: {
|
|
44
|
+
runner: Runner.name || 'runner',
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
: {};
|
|
48
|
+
return (await traceService.runWithEntrySpan(`oneshot ${Runner.name || 'runner'}`, {
|
|
49
|
+
enable: traceEnabled,
|
|
50
|
+
carrier: entryCarrier,
|
|
51
|
+
attributes: {
|
|
52
|
+
'midway.protocol': 'one-shot',
|
|
53
|
+
'midway.oneshot.runner': Runner.name || 'runner',
|
|
54
|
+
},
|
|
55
|
+
meta: traceMetaResolver,
|
|
56
|
+
metaArgs: {
|
|
57
|
+
ctx,
|
|
58
|
+
carrier: entryCarrier,
|
|
59
|
+
request: payload,
|
|
60
|
+
custom: {
|
|
61
|
+
runner: Runner.name || 'runner',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}, async () => {
|
|
65
|
+
const fn = await this.applyMiddleware(async (ctx) => {
|
|
66
|
+
const instance = (await ctx.requestContext.getAsync(Runner));
|
|
67
|
+
if (!instance?.run) {
|
|
68
|
+
throw new core_1.MidwayCommonError('One-shot runner must implement run().');
|
|
69
|
+
}
|
|
70
|
+
return await instance.run(payload, ctx);
|
|
71
|
+
});
|
|
72
|
+
return await fn(ctx);
|
|
73
|
+
}));
|
|
42
74
|
}
|
|
43
75
|
};
|
|
44
76
|
exports.MidwayOneShotFramework = MidwayOneShotFramework;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/one-shot",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.12",
|
|
4
4
|
"description": "Midway One-shot Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"lint": "mwts check"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@midwayjs/core": "^4.0.0-beta.
|
|
26
|
+
"@midwayjs/core": "^4.0.0-beta.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@midwayjs/mock": "^4.0.0-beta.
|
|
29
|
+
"@midwayjs/mock": "^4.0.0-beta.12"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=20"
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "1c48179b7c827ba8ec9351e9b6c36ec1726d3e11"
|
|
36
36
|
}
|