@routr/processor 2.18.0 → 2.19.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/dist/processor.d.ts +1 -0
- package/dist/processor.js +50 -0
- package/dist/response.d.ts +2 -1
- package/dist/response.js +3 -4
- package/package.json +3 -3
package/dist/processor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Response from "./response";
|
|
2
2
|
import { ProcessorConfig } from "./types";
|
|
3
3
|
import { MessageRequest, ServiceInfo } from "@routr/common";
|
|
4
|
+
export declare const VERSION_METADATA_KEY = "routr-component-version";
|
|
4
5
|
/**
|
|
5
6
|
* Processor is a class that handles the processing of a request.
|
|
6
7
|
*/
|
package/dist/processor.js
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.VERSION_METADATA_KEY = void 0;
|
|
6
40
|
/*
|
|
7
41
|
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
8
42
|
* http://github.com/fonoster/routr
|
|
@@ -22,7 +56,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
56
|
* limitations under the License.
|
|
23
57
|
*/
|
|
24
58
|
const response_1 = __importDefault(require("./response"));
|
|
59
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
25
60
|
const common_1 = require("@routr/common");
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
62
|
+
const VERSION = require("../package.json").version;
|
|
63
|
+
// gRPC metadata key under which every processor announces its version, so a
|
|
64
|
+
// dispatcher that records messages can write which build touched them
|
|
65
|
+
exports.VERSION_METADATA_KEY = "routr-component-version";
|
|
66
|
+
// eslint-disable-next-line require-jsdoc
|
|
67
|
+
const announceVersion = (call) => {
|
|
68
|
+
const sender = call;
|
|
69
|
+
if (typeof sender.sendMetadata !== "function")
|
|
70
|
+
return;
|
|
71
|
+
const md = new grpc.Metadata();
|
|
72
|
+
md.set(exports.VERSION_METADATA_KEY, VERSION);
|
|
73
|
+
sender.sendMetadata(md);
|
|
74
|
+
};
|
|
26
75
|
/**
|
|
27
76
|
* Processor is a class that handles the processing of a request.
|
|
28
77
|
*/
|
|
@@ -49,6 +98,7 @@ class Processor {
|
|
|
49
98
|
handlers: {
|
|
50
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
100
|
processMessage: (call, callback) => {
|
|
101
|
+
announceVersion(call);
|
|
52
102
|
func(call.request, new response_1.default(callback));
|
|
53
103
|
}
|
|
54
104
|
}
|
package/dist/response.d.ts
CHANGED
|
@@ -24,11 +24,12 @@ export default class Response {
|
|
|
24
24
|
*
|
|
25
25
|
* @param {MessageRequest} request - The request message.
|
|
26
26
|
* @param {object[]} extraHeaders - Optional extra headers to be sent.
|
|
27
|
+
* @param {Record<string, string>} metadata - Optional metadata for the dispatcher (e.g. the recording flag).
|
|
27
28
|
*/
|
|
28
29
|
sendRegisterOk(request: MessageRequest, extraHeaders?: Array<{
|
|
29
30
|
name: string;
|
|
30
31
|
value: string;
|
|
31
|
-
}>): void;
|
|
32
|
+
}>, metadata?: Record<string, string>): void;
|
|
32
33
|
/**
|
|
33
34
|
* Sends a method not allowed response.
|
|
34
35
|
*/
|
package/dist/response.js
CHANGED
|
@@ -57,11 +57,10 @@ class Response {
|
|
|
57
57
|
*
|
|
58
58
|
* @param {MessageRequest} request - The request message.
|
|
59
59
|
* @param {object[]} extraHeaders - Optional extra headers to be sent.
|
|
60
|
+
* @param {Record<string, string>} metadata - Optional metadata for the dispatcher (e.g. the recording flag).
|
|
60
61
|
*/
|
|
61
|
-
sendRegisterOk(request, extraHeaders) {
|
|
62
|
-
this.callback(null, {
|
|
63
|
-
message: Object.assign(Object.assign({}, buildResponse({ code: common_1.CommonTypes.ResponseType.OK, extraHeaders }).message), { contact: request.message.contact })
|
|
64
|
-
});
|
|
62
|
+
sendRegisterOk(request, extraHeaders, metadata) {
|
|
63
|
+
this.callback(null, Object.assign({ message: Object.assign(Object.assign({}, buildResponse({ code: common_1.CommonTypes.ResponseType.OK, extraHeaders }).message), { contact: request.message.contact }) }, (metadata && Object.keys(metadata).length ? { metadata } : {})));
|
|
65
64
|
}
|
|
66
65
|
/**
|
|
67
66
|
* Sends a method not allowed response.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/processor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"description": "Processor server and API",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@fonoster/logger": "0.6.0",
|
|
16
16
|
"@grpc/grpc-js": "~1.14.6",
|
|
17
17
|
"@grpc/proto-loader": "~0.7.10",
|
|
18
|
-
"@routr/common": "^2.
|
|
18
|
+
"@routr/common": "^2.19.0",
|
|
19
19
|
"fp-ts": "^2.11.8",
|
|
20
20
|
"phone": "^3.1.68"
|
|
21
21
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/fonoster/routr/issues"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "357116800e150d8bbfbd0ad2406689c5793675b1"
|
|
40
40
|
}
|