@restorecommerce/chassis-srv 0.3.12 → 1.0.0
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/CHANGELOG.md +5 -0
- package/lib/command-interface/index.d.ts +14 -13
- package/lib/command-interface/index.js +43 -65
- package/lib/command-interface/index.js.map +1 -1
- package/lib/database/index.d.ts +2 -1
- package/lib/database/index.js.map +1 -1
- package/lib/database/provider/arango/base.d.ts +1 -1
- package/lib/database/provider/arango/base.js.map +1 -1
- package/lib/database/provider/arango/graph.d.ts +3 -2
- package/lib/database/provider/arango/graph.js +4 -4
- package/lib/database/provider/arango/graph.js.map +1 -1
- package/lib/database/provider/arango/interface.d.ts +0 -65
- package/lib/database/provider/arango/interface.js +0 -43
- package/lib/database/provider/arango/interface.js.map +1 -1
- package/lib/database/provider/arango/utils.d.ts +1 -1
- package/lib/database/provider/arango/utils.js +7 -6
- package/lib/database/provider/arango/utils.js.map +1 -1
- package/lib/health/index.d.ts +5 -4
- package/lib/health/index.js +21 -38
- package/lib/health/index.js.map +1 -1
- package/lib/index.d.ts +6 -8
- package/lib/index.js +3 -6
- package/lib/index.js.map +1 -1
- package/lib/microservice/endpoint.d.ts +1 -16
- package/lib/microservice/endpoint.js +2 -214
- package/lib/microservice/endpoint.js.map +1 -1
- package/lib/microservice/server.d.ts +4 -3
- package/lib/microservice/server.js +8 -101
- package/lib/microservice/server.js.map +1 -1
- package/lib/microservice/transport/provider/grpc/index.d.ts +16 -11
- package/lib/microservice/transport/provider/grpc/index.js +20 -288
- package/lib/microservice/transport/provider/grpc/index.js.map +1 -1
- package/lib/microservice/transport/provider/grpc/middlewares.d.ts +7 -0
- package/lib/microservice/transport/provider/grpc/middlewares.js +55 -0
- package/lib/microservice/transport/provider/grpc/middlewares.js.map +1 -0
- package/lib/microservice/transport/provider/grpc/reflection.d.ts +7 -41
- package/lib/microservice/transport/provider/grpc/reflection.js +13 -519
- package/lib/microservice/transport/provider/grpc/reflection.js.map +1 -1
- package/package.json +22 -20
|
@@ -23,200 +23,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const path = __importStar(require("path"));
|
|
28
|
-
// import * as grpc from 'grpc';
|
|
26
|
+
exports.Server = exports.NAME = void 0;
|
|
29
27
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
30
|
-
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
31
28
|
const _ = __importStar(require("lodash"));
|
|
32
|
-
const
|
|
29
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
30
|
+
const middlewares_1 = require("./middlewares");
|
|
33
31
|
/**
|
|
34
32
|
* Name of the transport
|
|
35
|
-
*
|
|
36
|
-
* @const
|
|
37
33
|
*/
|
|
38
|
-
|
|
39
|
-
const errorMap = new Map([
|
|
40
|
-
[grpc.status.CANCELLED, errors.Cancelled],
|
|
41
|
-
[grpc.status.INVALID_ARGUMENT, errors.InvalidArgument],
|
|
42
|
-
[grpc.status.NOT_FOUND, errors.NotFound],
|
|
43
|
-
[grpc.status.ALREADY_EXISTS, errors.AlreadyExists],
|
|
44
|
-
[grpc.status.PERMISSION_DENIED, errors.PermissionDenied],
|
|
45
|
-
[grpc.status.UNAUTHENTICATED, errors.Unauthenticated],
|
|
46
|
-
[grpc.status.FAILED_PRECONDITION, errors.FailedPrecondition],
|
|
47
|
-
[grpc.status.ABORTED, errors.Aborted],
|
|
48
|
-
[grpc.status.OUT_OF_RANGE, errors.OutOfRange],
|
|
49
|
-
[grpc.status.UNIMPLEMENTED, errors.Unimplemented],
|
|
50
|
-
[grpc.status.RESOURCE_EXHAUSTED, errors.ResourceExhausted],
|
|
51
|
-
[grpc.status.DEADLINE_EXCEEDED, errors.DeadlineExceeded],
|
|
52
|
-
[grpc.status.INTERNAL, errors.Internal],
|
|
53
|
-
[grpc.status.UNAVAILABLE, errors.Unavailable],
|
|
54
|
-
[grpc.status.DATA_LOSS, errors.DataLoss],
|
|
55
|
-
]);
|
|
56
|
-
const makeNormalServerEndpoint = (endpoint, logger) => {
|
|
57
|
-
return async (call, callback) => {
|
|
58
|
-
const req = call.request;
|
|
59
|
-
if (!endpoint) {
|
|
60
|
-
return ({
|
|
61
|
-
code: grpc.status.UNIMPLEMENTED
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
let rid;
|
|
66
|
-
if (call && call.metadata) {
|
|
67
|
-
rid = call.metadata.get('rid');
|
|
68
|
-
}
|
|
69
|
-
if (rid && rid.length > 0) {
|
|
70
|
-
Object.assign(call.request, { headers: { 'x-request-id': rid[0] } });
|
|
71
|
-
}
|
|
72
|
-
const result = await endpoint(call);
|
|
73
|
-
callback(null, result);
|
|
74
|
-
}
|
|
75
|
-
catch (err) {
|
|
76
|
-
logger.error('Error invoking endpoint for unary request', { code: err.code, message: err.message, stack: err.stack });
|
|
77
|
-
err.code = grpc.status.INTERNAL;
|
|
78
|
-
errorMap.forEach((Err, key) => {
|
|
79
|
-
if (err.constructor.name === Err.name) {
|
|
80
|
-
err = new Err(err.details);
|
|
81
|
-
err.code = key;
|
|
82
|
-
}
|
|
83
|
-
}, errorMap);
|
|
84
|
-
callback(err, null);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
const makeResponseStreamServerEndpoint = (endpoint, logger) => {
|
|
89
|
-
return async (call) => {
|
|
90
|
-
try {
|
|
91
|
-
await endpoint({
|
|
92
|
-
request: call,
|
|
93
|
-
write: (response) => {
|
|
94
|
-
return call.write(response);
|
|
95
|
-
},
|
|
96
|
-
end: (err) => {
|
|
97
|
-
if (err) {
|
|
98
|
-
logger.error('Error invoking endpoint for response stream', { code: err.code, message: err.message, stack: err.stack });
|
|
99
|
-
err.code = grpc.status.INTERNAL;
|
|
100
|
-
errorMap.forEach((Err, key) => {
|
|
101
|
-
if (err.constructor.name === Err.name) {
|
|
102
|
-
err = new Err(err.details);
|
|
103
|
-
err.code = key;
|
|
104
|
-
}
|
|
105
|
-
}, errorMap);
|
|
106
|
-
call.emit('error', err);
|
|
107
|
-
}
|
|
108
|
-
call.end();
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
logger.error('Error invoking endpoint for streaming response', { code: err.code, message: err.message, stack: err.stack });
|
|
114
|
-
call.emit('error', err);
|
|
115
|
-
call.end();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
const makeRequestStreamServerEndpoint = (endpoint, logger) => {
|
|
120
|
-
return async (call, callback) => {
|
|
121
|
-
try {
|
|
122
|
-
const result = await endpoint({
|
|
123
|
-
getServerRequestStream: () => {
|
|
124
|
-
return call;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
callback(null, result);
|
|
128
|
-
}
|
|
129
|
-
catch (err) {
|
|
130
|
-
logger.error('Error invoking endpoint for request stream', { code: err.code, message: err.message, stack: err.stack });
|
|
131
|
-
err.code = grpc.status.INTERNAL;
|
|
132
|
-
errorMap.forEach((Err, key) => {
|
|
133
|
-
if (err.constructor.name === Err.name) {
|
|
134
|
-
err = new Err(err.details);
|
|
135
|
-
err.code = key;
|
|
136
|
-
}
|
|
137
|
-
}, errorMap);
|
|
138
|
-
callback(err, null);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
const makeBiDirectionalStreamServerEndpoint = (endpoint, logger) => {
|
|
143
|
-
return async (call) => {
|
|
144
|
-
const requests = [];
|
|
145
|
-
const fns = [];
|
|
146
|
-
let end = false;
|
|
147
|
-
call.on('data', (req) => {
|
|
148
|
-
if (fns.length) {
|
|
149
|
-
fns.shift()(null, req);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
requests.push(req);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
call.on('end', () => {
|
|
156
|
-
end = true;
|
|
157
|
-
while (fns.length) {
|
|
158
|
-
fns.shift()(new Error('stream end'), null);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
await (endpoint({
|
|
162
|
-
write: (response) => {
|
|
163
|
-
call.write(response);
|
|
164
|
-
},
|
|
165
|
-
read: () => {
|
|
166
|
-
return (cb) => {
|
|
167
|
-
if (requests.length) {
|
|
168
|
-
cb(null, requests.shift());
|
|
169
|
-
}
|
|
170
|
-
else if (end) {
|
|
171
|
-
throw new Error('stream end');
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
fns.push(cb);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
},
|
|
178
|
-
end: (err) => {
|
|
179
|
-
if (err) {
|
|
180
|
-
logger.error('Error invoking endpoint for bi-directional stream', { code: err.code, message: err.message, stack: err.stack });
|
|
181
|
-
err.code = grpc.status.INTERNAL;
|
|
182
|
-
errorMap.forEach((Err, key) => {
|
|
183
|
-
if (err.constructor.name === Err.name) {
|
|
184
|
-
err = new Err(err.details);
|
|
185
|
-
err.code = key;
|
|
186
|
-
}
|
|
187
|
-
}, errorMap);
|
|
188
|
-
call.emit('error', err);
|
|
189
|
-
}
|
|
190
|
-
call.end();
|
|
191
|
-
},
|
|
192
|
-
}));
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* wrapServerEndpoint wraps the endpoint to provide a gRPC service method.
|
|
197
|
-
*
|
|
198
|
-
* @param {generator} endpoint Endpoint which will be served as a gRPC service method.
|
|
199
|
-
* @param {object} stream Settings for request,response or bi directional stream.
|
|
200
|
-
* @return {function} The function can be used as a gRPC service method.
|
|
201
|
-
*/
|
|
202
|
-
const wrapServerEndpoint = (endpoint, logger, stream) => {
|
|
203
|
-
if (_.isNil(endpoint)) {
|
|
204
|
-
throw new Error('missing argument endpoint');
|
|
205
|
-
}
|
|
206
|
-
if (_.isNil(logger)) {
|
|
207
|
-
throw new Error('missing argument logger');
|
|
208
|
-
}
|
|
209
|
-
if (stream.requestStream && stream.responseStream) {
|
|
210
|
-
return makeBiDirectionalStreamServerEndpoint(endpoint, logger);
|
|
211
|
-
}
|
|
212
|
-
if (stream.requestStream) {
|
|
213
|
-
return makeRequestStreamServerEndpoint(endpoint, logger);
|
|
214
|
-
}
|
|
215
|
-
if (stream.responseStream) {
|
|
216
|
-
return makeResponseStreamServerEndpoint(endpoint, logger);
|
|
217
|
-
}
|
|
218
|
-
return makeNormalServerEndpoint(endpoint, logger);
|
|
219
|
-
};
|
|
34
|
+
exports.NAME = 'grpc';
|
|
220
35
|
/**
|
|
221
36
|
* Server transport provider.
|
|
222
37
|
* @class
|
|
@@ -226,8 +41,9 @@ class Server {
|
|
|
226
41
|
* Server is a gRPC transport provider for serving.
|
|
227
42
|
*
|
|
228
43
|
* @param {Object} config Configuration object.
|
|
229
|
-
* Requires properties:addr
|
|
44
|
+
* Requires properties: addr
|
|
230
45
|
* Optional properties: credentials.ssl.certs
|
|
46
|
+
* @param {Logger} logger Logger.
|
|
231
47
|
*/
|
|
232
48
|
constructor(config, logger) {
|
|
233
49
|
if (_.isNil(logger)) {
|
|
@@ -236,97 +52,21 @@ class Server {
|
|
|
236
52
|
if (!_.has(config, 'addr')) {
|
|
237
53
|
throw new Error('server is missing addr config field');
|
|
238
54
|
}
|
|
239
|
-
if (!_.has(config, 'services')) {
|
|
240
|
-
throw new Error('server is missing services config field');
|
|
241
|
-
}
|
|
242
55
|
this.config = config;
|
|
243
56
|
this.logger = logger;
|
|
244
|
-
// console['error'] = logger.debug;
|
|
245
|
-
// gRPC logger
|
|
246
57
|
grpc.setLogger(console);
|
|
247
|
-
this.server =
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
throw new Error('config value protoRoot is not set');
|
|
252
|
-
}
|
|
253
|
-
const protos = config.protos;
|
|
254
|
-
if (_.isNil(protos) || _.size(protos) === 0) {
|
|
255
|
-
throw new Error('config value protos is not set');
|
|
256
|
-
}
|
|
257
|
-
this.logger.verbose(`gRPC Server loading protobuf files from root ${protoRoot}`, { protos });
|
|
258
|
-
const proto = [];
|
|
259
|
-
for (let i = 0; i < protos.length; i++) {
|
|
260
|
-
const filePath = path.resolve(protoRoot, protos[i]);
|
|
261
|
-
const packageDefinition = protoLoader.loadSync(filePath, {
|
|
262
|
-
includeDirs: [protoRoot],
|
|
263
|
-
keepCase: true,
|
|
264
|
-
longs: String,
|
|
265
|
-
enums: String,
|
|
266
|
-
defaults: true,
|
|
267
|
-
oneofs: true
|
|
268
|
-
});
|
|
269
|
-
// this.proto = grpc.load(filePath, 'proto', {
|
|
270
|
-
// longsAsStrings: false
|
|
271
|
-
// });
|
|
272
|
-
this.proto = grpc.loadPackageDefinition(packageDefinition);
|
|
273
|
-
proto[i] = this.proto;
|
|
274
|
-
}
|
|
275
|
-
let k = 0;
|
|
276
|
-
this.service = _.transform(this.config.services, (service, protobufServiceName, serviceName) => {
|
|
277
|
-
const serviceDef = _.get(proto[k], protobufServiceName);
|
|
278
|
-
if (_.isNil(serviceDef)) {
|
|
279
|
-
throw new Error(`Could not find ${protobufServiceName} protobuf service`);
|
|
280
|
-
}
|
|
281
|
-
_.set(service, serviceName, serviceDef.service);
|
|
282
|
-
k++;
|
|
283
|
-
logger.verbose('gRPC service loaded', serviceName);
|
|
284
|
-
});
|
|
285
|
-
this.name = NAME;
|
|
58
|
+
this.server = (0, nice_grpc_1.createServer)()
|
|
59
|
+
.use(middlewares_1.tracingMiddleware)
|
|
60
|
+
.use((0, middlewares_1.loggingMiddleware)(this.logger));
|
|
61
|
+
this.name = exports.NAME;
|
|
286
62
|
}
|
|
287
63
|
/**
|
|
288
64
|
* bind maps the service to gRPC methods and binds the address.
|
|
289
65
|
*
|
|
290
|
-
* @param
|
|
291
|
-
* @param {Object} service Business logic
|
|
66
|
+
* @param {BindConfig} config Service bind config.
|
|
292
67
|
*/
|
|
293
|
-
bind(
|
|
294
|
-
|
|
295
|
-
throw new Error('missing argument name');
|
|
296
|
-
}
|
|
297
|
-
if (!_.isString(name)) {
|
|
298
|
-
throw new Error('argument name is not of type string');
|
|
299
|
-
}
|
|
300
|
-
if (_.isNil(service)) {
|
|
301
|
-
throw new Error('missing argument service');
|
|
302
|
-
}
|
|
303
|
-
const protoService = this.service[name];
|
|
304
|
-
if (_.isNil(protoService)) {
|
|
305
|
-
throw new Error(`service ${name} does not exist in transport ${this.name}`);
|
|
306
|
-
}
|
|
307
|
-
// wrap all service methods
|
|
308
|
-
const binding = {};
|
|
309
|
-
const funcs = _.functionsIn(service);
|
|
310
|
-
if (funcs.length === 0) {
|
|
311
|
-
throw new Error('service object does not have functions');
|
|
312
|
-
}
|
|
313
|
-
for (let i = 0; i < funcs.length; i += 1) {
|
|
314
|
-
const methodName = funcs[i];
|
|
315
|
-
const methods = protoService;
|
|
316
|
-
const methodDef = _.find(methods, (m) => {
|
|
317
|
-
return m.originalName.toLowerCase() === methodName.toLowerCase();
|
|
318
|
-
});
|
|
319
|
-
const stream = {
|
|
320
|
-
requestStream: false,
|
|
321
|
-
responseStream: false,
|
|
322
|
-
};
|
|
323
|
-
if (methodDef) {
|
|
324
|
-
stream.requestStream = methodDef.requestStream;
|
|
325
|
-
stream.responseStream = methodDef.responseStream;
|
|
326
|
-
}
|
|
327
|
-
binding[methodName] = wrapServerEndpoint(service[methodName], this.logger, stream);
|
|
328
|
-
}
|
|
329
|
-
this.server.addService(protoService, binding);
|
|
68
|
+
bind(config) {
|
|
69
|
+
this.server.add(config.service, config.implementation);
|
|
330
70
|
}
|
|
331
71
|
/**
|
|
332
72
|
* start launches the gRPC server and provides the service endpoints.
|
|
@@ -335,33 +75,25 @@ class Server {
|
|
|
335
75
|
if (!this.isBound) {
|
|
336
76
|
let credentials = grpc.ServerCredentials.createInsecure();
|
|
337
77
|
if (_.has(this.config, 'credentials.ssl')) {
|
|
338
|
-
|
|
78
|
+
// TODO Re-enable
|
|
79
|
+
// credentials = grpc.credentials.createSsl(
|
|
80
|
+
// this.config.credentials.ssl.certs);
|
|
339
81
|
}
|
|
340
82
|
new Promise((resolve, reject) => {
|
|
341
|
-
this.server.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
throw err;
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
resolve(this.server.start());
|
|
348
|
-
}
|
|
83
|
+
this.server.listen(this.config.addr, credentials).then(resolve).catch(err => {
|
|
84
|
+
this.logger.error('Error starting server', { message: err.message, stack: err.stack });
|
|
85
|
+
reject(err);
|
|
349
86
|
});
|
|
350
87
|
});
|
|
351
88
|
this.isBound = true;
|
|
352
89
|
}
|
|
353
|
-
// this.server.start();
|
|
354
90
|
}
|
|
355
91
|
/**
|
|
356
92
|
* end stops the gRPC server and no longer provides the service endpoints.
|
|
357
93
|
*/
|
|
358
94
|
async end() {
|
|
359
|
-
|
|
360
|
-
server.forceShutdown();
|
|
95
|
+
this.server.forceShutdown();
|
|
361
96
|
}
|
|
362
97
|
}
|
|
363
98
|
exports.Server = Server;
|
|
364
|
-
module.exports.Name = NAME;
|
|
365
|
-
const reflection_1 = require("./reflection");
|
|
366
|
-
Object.defineProperty(exports, "ServerReflection", { enumerable: true, get: function () { return reflection_1.ServerReflection; } });
|
|
367
99
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/microservice/transport/provider/grpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,gCAAgC;AAChC,oDAAsC;AACtC,gEAAkD;AAClD,0CAA4B;AAC5B,wDAA0C;AAG1C;;;;GAIG;AACH,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;IACvB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;IACzC,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,eAAe,CA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AAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;wBACvF,MAAM,GAAG,CAAC;qBACX;yBAAM;wBACL,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;qBAC9B;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACrB;QACD,uBAAuB;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;CACF;AA7JD,wBA6JC;AAED,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;AAC3B,6CAAgD;AACvC,iGADA,6BAAgB,OACA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/microservice/transport/provider/grpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,0CAA4B;AAI5B,yCAAyC;AACzC,+CAAoF;AAEpF;;GAEG;AACU,QAAA,IAAI,GAAG,MAAM,CAAC;AAO3B;;;GAGG;AACH,MAAa,MAAM;IAQjB;;;;;;;OAOG;IACH,YAAY,MAAW,EAAE,MAAc;QACrC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAExB,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CAAC;CACF;AAvED,wBAuEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CallContext, ServerMiddlewareCall } from 'nice-grpc';
|
|
2
|
+
import { Logger } from 'winston';
|
|
3
|
+
export interface WithRequestID {
|
|
4
|
+
rid: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function tracingMiddleware<Request, Response>(call: ServerMiddlewareCall<Request, Response, WithRequestID>, context: CallContext): AsyncGenerator<Awaited<Response>, void | Awaited<Response>, undefined>;
|
|
7
|
+
export declare const loggingMiddleware: (logger: Logger) => <Request_1, Response_1>(call: ServerMiddlewareCall<Request_1, Response_1, {}>, context: CallContext & WithRequestID) => AsyncGenerator<Awaited<Response_1>, void | Awaited<Response_1>, undefined>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loggingMiddleware = exports.tracingMiddleware = void 0;
|
|
4
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
5
|
+
const abort_controller_x_1 = require("abort-controller-x");
|
|
6
|
+
const uuid_1 = require("uuid");
|
|
7
|
+
const tracingHeader = 'x-request-id';
|
|
8
|
+
async function* tracingMiddleware(call, context) {
|
|
9
|
+
const nextID = context.metadata.get(tracingHeader) || (0, uuid_1.v1)();
|
|
10
|
+
context.metadata?.set(tracingHeader, nextID);
|
|
11
|
+
return yield* call.next(call.request, {
|
|
12
|
+
...context,
|
|
13
|
+
rid: nextID
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.tracingMiddleware = tracingMiddleware;
|
|
17
|
+
const loggingMiddleware = (logger) => {
|
|
18
|
+
return async function* (call, context) {
|
|
19
|
+
const { path } = call.method;
|
|
20
|
+
logger.verbose(`[rid: ${context.rid}] received request to method ${path}`, call);
|
|
21
|
+
try {
|
|
22
|
+
const response = yield* call.next(call.request, context);
|
|
23
|
+
logger.verbose(`[rid: ${context.rid}] request to method ${path} response`, { request: call, response });
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof nice_grpc_1.ServerError) {
|
|
28
|
+
logger.error(`${context.rid} request to method ${path} server error`, {
|
|
29
|
+
message: error.details,
|
|
30
|
+
code: error.code
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if ((0, abort_controller_x_1.isAbortError)(error)) {
|
|
34
|
+
logger.error(`${context.rid} request to method ${path} cancel`, {
|
|
35
|
+
message: error.message,
|
|
36
|
+
stack: error.stack
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
logger.error(`${context.rid} request to method ${path} error`, {
|
|
41
|
+
message: error.message,
|
|
42
|
+
stack: error.stack
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
status: {
|
|
47
|
+
code: 500,
|
|
48
|
+
message: error.message
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.loggingMiddleware = loggingMiddleware;
|
|
55
|
+
//# sourceMappingURL=middlewares.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../../src/microservice/transport/provider/grpc/middlewares.ts"],"names":[],"mappings":";;;AAAA,yCAA2E;AAC3E,2DAAkD;AAElD,+BAAoC;AAEpC,MAAM,aAAa,GAAG,cAAc,CAAC;AAM9B,KAAK,SAAS,CAAC,CAAC,iBAAiB,CACtC,IAA4D,EAC5D,OAAoB;IAEpB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAA,SAAM,GAAE,CAAC;IAC/D,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO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E,KAAK,CAAC,OAAO;oBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;iBACnB,CAAC,CAAC;aACJ;YAED,OAAO;gBACL,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG;oBACT,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACmB,CAAC;SACxB;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,iBAAiB,qBAuC5B"}
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
config: any;
|
|
9
|
-
fileDescriptorProto: protoBuf.Type;
|
|
10
|
-
/**
|
|
11
|
-
* @param (ProtoBuf.Builder) The protobuf builder which the gRPC transport provider is using.
|
|
12
|
-
* @config (Object) Server cofnig.
|
|
13
|
-
*/
|
|
14
|
-
constructor(root: protoBuf.Root, config: any);
|
|
15
|
-
/**
|
|
16
|
-
* Service endpoint for gRPC ServerReflectionInfo.
|
|
17
|
-
*/
|
|
18
|
-
serverReflectionInfo(call?: any, context?: any): Promise<any>;
|
|
19
|
-
/**
|
|
20
|
-
* Find a proto file by the file name.
|
|
21
|
-
*/
|
|
22
|
-
fileByFilename(fileName: string, req: any): any;
|
|
23
|
-
/**
|
|
24
|
-
* Find a proto file by a symbol.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} path Path to symbol
|
|
27
|
-
* Format: <package>.<service>[.<method>] or <package>.<type>)
|
|
28
|
-
*/
|
|
29
|
-
findProtoFileByPath(path: string, req: any): any;
|
|
30
|
-
/**
|
|
31
|
-
* Find the proto file which defines an extension extending the given
|
|
32
|
-
* message type with the given field number.
|
|
33
|
-
*/
|
|
34
|
-
fileContainingExtension(arg: any, req: any): any;
|
|
35
|
-
allExtensionNumbersOfType(path: string, req: any): any;
|
|
36
|
-
/**
|
|
37
|
-
* Lists all gRPC provided services.
|
|
38
|
-
* NOTE: Services using other transport providers are not listed.
|
|
39
|
-
*/
|
|
40
|
-
listServices(req: any): any;
|
|
41
|
-
}
|
|
1
|
+
import { ServiceImplementation } from 'nice-grpc';
|
|
2
|
+
import { FileDescriptorProto } from '@restorecommerce/rc-grpc-clients/dist/generated/google/protobuf/descriptor';
|
|
3
|
+
import { IServerReflectionService } from 'nice-grpc-server-reflection/lib/proto/grpc/reflection/v1alpha/reflection_grpc_pb';
|
|
4
|
+
export declare const buildReflectionService: (services: {
|
|
5
|
+
descriptor: FileDescriptorProto;
|
|
6
|
+
name?: string;
|
|
7
|
+
}[]) => ServiceImplementation<IServerReflectionService>;
|