@sentio/runtime 2.37.3-rc.6 → 2.38.0-rc.1
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/lib/processor-runner.js
CHANGED
@@ -8,6 +8,8 @@ import { errorDetailsServerMiddleware } from 'nice-grpc-error-details';
|
|
8
8
|
import { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus';
|
9
9
|
import { register as globalRegistry, Registry } from 'prom-client';
|
10
10
|
import http from 'http';
|
11
|
+
// @ts-ignore inspector promises is not included in @type/node
|
12
|
+
import { Session } from 'node:inspector/promises';
|
11
13
|
import { ProcessorDefinition } from './gen/processor/protos/processor.js';
|
12
14
|
import { ProcessorServiceImpl } from './service.js';
|
13
15
|
import { Endpoints } from './endpoints.js';
|
@@ -74,9 +76,35 @@ console.log('Processor Server Started at:', options.port);
|
|
74
76
|
const metricsPort = 4040;
|
75
77
|
const httpServer = http
|
76
78
|
.createServer(async function (req, res) {
|
77
|
-
if (req.url
|
78
|
-
const
|
79
|
-
|
79
|
+
if (req.url) {
|
80
|
+
const reqUrl = new URL(req.url, `http://${req.headers.host}`);
|
81
|
+
const queries = reqUrl.searchParams;
|
82
|
+
switch (reqUrl.pathname) {
|
83
|
+
case '/metrics':
|
84
|
+
const metrics = await mergedRegistry.metrics();
|
85
|
+
res.write(metrics);
|
86
|
+
break;
|
87
|
+
case '/profile': {
|
88
|
+
try {
|
89
|
+
const profileTime = parseInt(queries.get('t') || '1000', 10) || 1000;
|
90
|
+
const session = new Session();
|
91
|
+
session.connect();
|
92
|
+
await session.post('Profiler.enable');
|
93
|
+
await session.post('Profiler.start');
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, profileTime));
|
95
|
+
const { profile } = await session.post('Profiler.stop');
|
96
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
97
|
+
res.write(JSON.stringify(profile));
|
98
|
+
session.disconnect();
|
99
|
+
}
|
100
|
+
catch {
|
101
|
+
res.writeHead(500);
|
102
|
+
}
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
default:
|
106
|
+
res.writeHead(404);
|
107
|
+
}
|
80
108
|
}
|
81
109
|
else {
|
82
110
|
res.writeHead(404);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,IAAI,MAAM,MAAM,CAAA;
|
1
|
+
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,IAAI,MAAM,MAAM,CAAA;A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 -32,7 +32,7 @@
|
|
32
32
|
"rxjs": "^7.8.1",
|
33
33
|
"utility-types": "^3.11.0",
|
34
34
|
"winston": "^3.11.0",
|
35
|
-
"@sentio/protos": "2.
|
35
|
+
"@sentio/protos": "2.38.0-rc.1"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"@types/command-line-args": "^5.2.3",
|
package/src/processor-runner.ts
CHANGED
@@ -10,6 +10,8 @@ import { errorDetailsServerMiddleware } from 'nice-grpc-error-details'
|
|
10
10
|
import { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus'
|
11
11
|
import { register as globalRegistry, Registry } from 'prom-client'
|
12
12
|
import http from 'http'
|
13
|
+
// @ts-ignore inspector promises is not included in @type/node
|
14
|
+
import { Session } from 'node:inspector/promises'
|
13
15
|
|
14
16
|
import { ProcessorDefinition } from './gen/processor/protos/processor.js'
|
15
17
|
import { ProcessorServiceImpl } from './service.js'
|
@@ -90,9 +92,37 @@ console.log('Processor Server Started at:', options.port)
|
|
90
92
|
const metricsPort = 4040
|
91
93
|
const httpServer = http
|
92
94
|
.createServer(async function (req, res) {
|
93
|
-
if (req.url
|
94
|
-
const
|
95
|
-
|
95
|
+
if (req.url) {
|
96
|
+
const reqUrl = new URL(req.url, `http://${req.headers.host}`)
|
97
|
+
const queries = reqUrl.searchParams
|
98
|
+
switch (reqUrl.pathname) {
|
99
|
+
case '/metrics':
|
100
|
+
const metrics = await mergedRegistry.metrics()
|
101
|
+
res.write(metrics)
|
102
|
+
break
|
103
|
+
case '/profile': {
|
104
|
+
try {
|
105
|
+
const profileTime = parseInt(queries.get('t') || '1000', 10) || 1000
|
106
|
+
const session = new Session()
|
107
|
+
session.connect()
|
108
|
+
|
109
|
+
await session.post('Profiler.enable')
|
110
|
+
await session.post('Profiler.start')
|
111
|
+
|
112
|
+
await new Promise((resolve) => setTimeout(resolve, profileTime))
|
113
|
+
const { profile } = await session.post('Profiler.stop')
|
114
|
+
|
115
|
+
res.writeHead(200, { 'Content-Type': 'application/json' })
|
116
|
+
res.write(JSON.stringify(profile))
|
117
|
+
session.disconnect()
|
118
|
+
} catch {
|
119
|
+
res.writeHead(500)
|
120
|
+
}
|
121
|
+
break
|
122
|
+
}
|
123
|
+
default:
|
124
|
+
res.writeHead(404)
|
125
|
+
}
|
96
126
|
} else {
|
97
127
|
res.writeHead(404)
|
98
128
|
}
|