@routr/echo 2.0.5-alpha.2 → 2.0.5-alpha.20

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/runner.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /*
8
- * Copyright (C) 2021 by Fonoster Inc (https://fonoster.com)
8
+ * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
9
9
  * http://github.com/fonoster/routr
10
10
  *
11
11
  * This file is part of Routr
@@ -22,7 +22,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  * See the License for the specific language governing permissions and
23
23
  * limitations under the License.
24
24
  */
25
- var service_1 = __importDefault(require("./service"));
26
- var bindAddr = process.env.BIND_ADDR || "0.0.0.0:51903";
27
- // TODO: Get config from file
28
- service_1.default({ bindAddr: bindAddr });
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ require("./tracer").init("dispatcher");
27
+ const processor_1 = __importDefault(require("@routr/processor"));
28
+ const logger_1 = require("@fonoster/logger");
29
+ const logger = (0, logger_1.getLogger)({ service: "location", filePath: __filename });
30
+ new processor_1.default({
31
+ bindAddr: process.env.BIND_ADDR || "0.0.0.0:51904",
32
+ name: "echo"
33
+ }).listen((req, res) => {
34
+ logger.verbose("got new request: ");
35
+ logger.verbose(JSON.stringify(req, null, " "));
36
+ res.sendOk();
37
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This function registers the instrumentations for the service.
3
+ *
4
+ * @param {string} serviceName - The name of the service.
5
+ * @return {Tracer} The tracer object.
6
+ */
7
+ export declare function init(serviceName: string): import("@opentelemetry/api").Tracer;
package/dist/tracer.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
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
+ /**
34
+ * This function registers the instrumentations for the service.
35
+ *
36
+ * @param {string} serviceName - The name of the service.
37
+ * @return {Tracer} The tracer object.
38
+ */
39
+ function init(serviceName) {
40
+ const provider = new sdk_trace_node_1.NodeTracerProvider({
41
+ resource: new resources_1.Resource({
42
+ [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: serviceName
43
+ })
44
+ });
45
+ const exporter = new exporter_jaeger_1.JaegerExporter();
46
+ provider.addSpanProcessor(new sdk_trace_base_1.SimpleSpanProcessor(exporter));
47
+ provider.register();
48
+ (0, instrumentation_1.registerInstrumentations)({
49
+ instrumentations: [new instrumentation_grpc_1.GrpcInstrumentation()]
50
+ });
51
+ return api_1.default.trace.getTracer("routr-tracer");
52
+ }
53
+ exports.init = init;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/echo",
3
- "version": "2.0.5-alpha.2",
3
+ "version": "2.0.5-alpha.20",
4
4
  "description": "Dummy implementation of a Processor service",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -19,8 +19,17 @@
19
19
  "run_echo": "dist/runner.js"
20
20
  },
21
21
  "dependencies": {
22
- "@fonoster/logger": "^0.3.3",
23
- "@routr/common": "^2.0.5-alpha.2"
22
+ "@fonoster/logger": "0.3.17-alpha.2",
23
+ "@opentelemetry/api": "^1.0.4",
24
+ "@opentelemetry/exporter-jaeger": "^1.0.4",
25
+ "@opentelemetry/instrumentation": "^0.27.0",
26
+ "@opentelemetry/instrumentation-grpc": "^0.27.0",
27
+ "@opentelemetry/resources": "^1.0.4",
28
+ "@opentelemetry/sdk-trace-base": "^1.0.4",
29
+ "@opentelemetry/sdk-trace-node": "^1.0.4",
30
+ "@opentelemetry/semantic-conventions": "^1.0.4",
31
+ "@routr/common": "^2.0.5-alpha.20",
32
+ "@routr/processor": "^2.0.5-alpha.20"
24
33
  },
25
34
  "files": [
26
35
  "dist"
@@ -35,5 +44,5 @@
35
44
  "bugs": {
36
45
  "url": "https://github.com/fonoster/routr/issues"
37
46
  },
38
- "gitHead": "3570106be9a96cb6672de4a850a377bfa7d9bb3e"
47
+ "gitHead": "be3a515d8c24aaae86ef076b65880c2e89415dcb"
39
48
  }
@@ -1,9 +0,0 @@
1
- export declare function processMessage(call: any, callback: Function): void;
2
- export declare const serviceInfo: {
3
- name: string;
4
- bindAddr: string;
5
- service: any;
6
- handlers: {
7
- processMessage: typeof processMessage;
8
- };
9
- };
package/dist/processor.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.serviceInfo = exports.processMessage = void 0;
18
- /*
19
- * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
20
- * http://github.com/fonoster/routr
21
- *
22
- * This file is part of Routr
23
- *
24
- * Licensed under the MIT License (the "License")
25
- * you may not use this file except in compliance with
26
- * the License. You may obtain a copy of the License at
27
- *
28
- * https://opensource.org/licenses/MIT
29
- *
30
- * Unless required by applicable law or agreed to in writing, software
31
- * distributed under the License is distributed on an "AS IS" BASIS,
32
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
- * See the License for the specific language governing permissions and
34
- * limitations under the License.
35
- */
36
- var common_1 = require("@routr/common");
37
- var logger_1 = __importDefault(require("@fonoster/logger"));
38
- // This processor returns upstream the message received
39
- function processMessage(call, callback) {
40
- logger_1.default.verbose("got new request: ");
41
- logger_1.default.verbose(JSON.stringify(call.request, null, ' '));
42
- var response = {
43
- request_type: call.request.request_type,
44
- message: __assign({}, call.request.message)
45
- };
46
- callback(null, response);
47
- }
48
- exports.processMessage = processMessage;
49
- exports.serviceInfo = {
50
- name: "echo",
51
- bindAddr: 'placeholder',
52
- service: common_1.PROCESSOR_OBJECT_PROTO.Processor.service,
53
- handlers: { processMessage: processMessage }
54
- };
package/dist/service.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { EchoProcessorConfig } from "./types";
2
- export default function EchoProcessor(config: EchoProcessorConfig): void;
package/dist/service.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
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
- var common_1 = require("@routr/common");
22
- var processor_1 = require("./processor");
23
- function EchoProcessor(config) {
24
- processor_1.serviceInfo.bindAddr = config.bindAddr;
25
- common_1.createService(processor_1.serviceInfo);
26
- }
27
- exports.default = EchoProcessor;
package/dist/types.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export interface EchoProcessorConfig {
2
- bindAddr: string;
3
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });