@routr/dispatcher 2.0.5-alpha.14 → 2.0.5-alpha.15
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/config/get_config.js +5 -1
- package/dist/find_processor.js +2 -2
- package/dist/processor.js +5 -5
- package/dist/run_processor.js +5 -30
- package/dist/runner.js +2 -2
- package/dist/service.js +20 -1
- package/dist/tracer.d.ts +1 -1
- package/dist/tracer.js +39 -31
- package/dist/util.js +1 -1
- package/package.json +11 -4
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/find_processor.js
CHANGED
|
@@ -5,9 +5,9 @@ const errors_1 = require("./errors");
|
|
|
5
5
|
const hasMethod = (config, request) => config.methods.includes(request.method);
|
|
6
6
|
exports.hasMethod = hasMethod;
|
|
7
7
|
// TODO: We need a way to test the matching function
|
|
8
|
-
const filter = (request, config) => exports.hasMethod(config, request)
|
|
8
|
+
const filter = (request, config) => (0, exports.hasMethod)(config, request)
|
|
9
9
|
&& (config.isFallback || config.matchFunc(request));
|
|
10
10
|
exports.filter = filter;
|
|
11
|
-
const findProcessor = (list) => (request) => list.find((config) => exports.filter(request, config))
|
|
11
|
+
const findProcessor = (list) => (request) => list.find((config) => (0, exports.filter)(request, config))
|
|
12
12
|
|| new errors_1.NotMatchingProcessorFound(request.ref);
|
|
13
13
|
exports.findProcessor = findProcessor;
|
package/dist/processor.js
CHANGED
|
@@ -27,23 +27,23 @@ const run_middlewares_1 = require("./run_middlewares");
|
|
|
27
27
|
const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
28
28
|
function processor(params) {
|
|
29
29
|
const { processors, middlewares } = params;
|
|
30
|
-
const procConns = connections_1.default(processors);
|
|
31
|
-
const middConns = connections_1.default(middlewares);
|
|
30
|
+
const procConns = (0, connections_1.default)(processors);
|
|
31
|
+
const middConns = (0, connections_1.default)(middlewares);
|
|
32
32
|
// Upstream request and callback
|
|
33
33
|
return (call, callback) => {
|
|
34
34
|
const { request } = call;
|
|
35
35
|
// Messages type reponse will not be sent to middleware chain
|
|
36
36
|
if (request.message.messageType === 'responseType') {
|
|
37
|
-
return run_processor_1.runProcessor({ callback, request, processors, connections: procConns });
|
|
37
|
+
return (0, run_processor_1.runProcessor)({ callback, request, processors, connections: procConns });
|
|
38
38
|
}
|
|
39
|
-
run_middlewares_1.runMiddlewares({ callback, request, middlewares, connections: middConns })
|
|
39
|
+
(0, run_middlewares_1.runMiddlewares)({ callback, request, middlewares, connections: middConns })
|
|
40
40
|
.then((req) => {
|
|
41
41
|
// Since the chain was broken we need to skip the processor and return the updated request
|
|
42
42
|
if (req.message.messageType === "responseType") {
|
|
43
43
|
logger_1.default.verbose("skipped processsing request ref " + req.ref);
|
|
44
44
|
return callback(null, req);
|
|
45
45
|
}
|
|
46
|
-
run_processor_1.runProcessor({ callback, request: req, processors, connections: procConns });
|
|
46
|
+
(0, run_processor_1.runProcessor)({ callback, request: req, processors, connections: procConns });
|
|
47
47
|
})
|
|
48
48
|
.catch(callback);
|
|
49
49
|
};
|
package/dist/run_processor.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
@@ -45,22 +26,16 @@ const errors_1 = require("./errors");
|
|
|
45
26
|
const find_processor_1 = require("./find_processor");
|
|
46
27
|
const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
47
28
|
const grpc = require("@grpc/grpc-js");
|
|
48
|
-
const
|
|
49
|
-
// import { Tracer as T } from '@routr/common'
|
|
50
|
-
// const tracer = T.init('example-grpc-js-server');
|
|
51
|
-
const Tracer = __importStar(require("./tracer"));
|
|
52
|
-
const tracer = Tracer.init('dispatcher');
|
|
29
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
53
30
|
function runProcessor(params) {
|
|
54
|
-
const currentSpan =
|
|
31
|
+
const currentSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
|
55
32
|
// display traceid in the terminal
|
|
56
33
|
logger_1.default.verbose(`traceid: ${currentSpan.spanContext().traceId}`);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
attributes: { key: 'value' },
|
|
60
|
-
});
|
|
34
|
+
const tracer = api_1.default.trace.getTracer("routr-tracer");
|
|
35
|
+
const span = tracer.startSpan('server.js:sayHello()', { kind: 1 });
|
|
61
36
|
span.addEvent(`invoking sayHello() to...`);
|
|
62
37
|
const { callback, connections, processors, request } = params;
|
|
63
|
-
const matchResult = find_processor_1.findProcessor(processors)(request);
|
|
38
|
+
const matchResult = (0, find_processor_1.findProcessor)(processors)(request);
|
|
64
39
|
if ('code' in matchResult) {
|
|
65
40
|
return callback(matchResult);
|
|
66
41
|
}
|
package/dist/runner.js
CHANGED
|
@@ -25,9 +25,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
const service_1 = __importDefault(require("./service"));
|
|
26
26
|
const get_config_1 = require("./config/get_config");
|
|
27
27
|
const logger_1 = __importDefault(require("@fonoster/logger"));
|
|
28
|
-
const result = get_config_1.getConfig(process.env.CONFIG_PATH);
|
|
28
|
+
const result = (0, get_config_1.getConfig)(process.env.CONFIG_PATH);
|
|
29
29
|
if (result._tag === 'Right') {
|
|
30
|
-
service_1.default(result.right);
|
|
30
|
+
(0, service_1.default)(result.right);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
logger_1.default.error(result.left);
|
package/dist/service.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License")
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
require("./tracer").init("dispatcher");
|
|
3
22
|
const common_1 = require("@routr/common");
|
|
4
23
|
const util_1 = require("./util");
|
|
5
24
|
function MessageDispatcher(config) {
|
|
6
25
|
const { bindAddr, processors, middlewares } = config;
|
|
7
|
-
common_1.createService(util_1.getServiceInfo(bindAddr, { processors, middlewares }));
|
|
26
|
+
(0, common_1.createService)((0, util_1.getServiceInfo)(bindAddr, { processors, middlewares }));
|
|
8
27
|
}
|
|
9
28
|
exports.default = MessageDispatcher;
|
package/dist/tracer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function init(serviceName: string): import("@opentelemetry/api").Tracer;
|
package/dist/tracer.js
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.init = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/routr
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Routr
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License")
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const api_1 = __importDefault(require("@opentelemetry/api"));
|
|
26
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
27
|
+
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
28
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
29
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
30
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
31
|
+
const exporter_jaeger_1 = require("@opentelemetry/exporter-jaeger");
|
|
32
|
+
const instrumentation_grpc_1 = require("@opentelemetry/instrumentation-grpc");
|
|
33
|
+
function init(serviceName) {
|
|
34
|
+
const provider = new sdk_trace_node_1.NodeTracerProvider({
|
|
35
|
+
resource: new resources_1.Resource({
|
|
36
|
+
[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
18
37
|
}),
|
|
19
38
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exporter = new ZipkinExporter();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
exporter = new JaegerExporter({
|
|
26
|
-
endpoint: "http://jaeger:14268/api/traces",
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
console.log("XXXXXXXXX STARTING PROVIDER");
|
|
30
|
-
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
|
|
31
|
-
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
|
|
39
|
+
const exporter = new exporter_jaeger_1.JaegerExporter();
|
|
40
|
+
provider.addSpanProcessor(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
|
|
32
41
|
provider.register();
|
|
33
|
-
registerInstrumentations({
|
|
42
|
+
(0, instrumentation_1.registerInstrumentations)({
|
|
34
43
|
instrumentations: [
|
|
35
|
-
new GrpcInstrumentation(),
|
|
44
|
+
new instrumentation_grpc_1.GrpcInstrumentation(),
|
|
36
45
|
],
|
|
37
46
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
47
|
+
return api_1.default.trace.getTracer('routr-tracer');
|
|
48
|
+
}
|
|
41
49
|
exports.init = init;
|
package/dist/util.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/dispatcher",
|
|
3
|
-
"version": "2.0.5-alpha.
|
|
3
|
+
"version": "2.0.5-alpha.15",
|
|
4
4
|
"description": "Receives SIP messages and forwards them to the corresponding Message Processor",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -26,8 +26,15 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@grpc/grpc-js": "^1.5.9",
|
|
29
|
-
"@opentelemetry/api": "^1.
|
|
30
|
-
"@
|
|
29
|
+
"@opentelemetry/api": "^1.0.4",
|
|
30
|
+
"@opentelemetry/exporter-jaeger": "^1.0.4",
|
|
31
|
+
"@opentelemetry/instrumentation": "^0.27.0",
|
|
32
|
+
"@opentelemetry/instrumentation-grpc": "^0.27.0",
|
|
33
|
+
"@opentelemetry/resources": "^1.0.4",
|
|
34
|
+
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
35
|
+
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
36
|
+
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
37
|
+
"@routr/common": "^2.0.5-alpha.15",
|
|
31
38
|
"ajv": "^6.12.6",
|
|
32
39
|
"fp-ts": "^2.11.8"
|
|
33
40
|
},
|
|
@@ -38,5 +45,5 @@
|
|
|
38
45
|
"bugs": {
|
|
39
46
|
"url": "https://github.com/fonoster/routr/issues"
|
|
40
47
|
},
|
|
41
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3e08aa86f1596252546134bff677d17d7dd54ced"
|
|
42
49
|
}
|