@routr/dispatcher 2.0.5-alpha.2 → 2.0.5-alpha.3

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.
@@ -1,15 +1,4 @@
1
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
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -34,21 +23,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
23
  };
35
24
  Object.defineProperty(exports, "__esModule", { value: true });
36
25
  exports.getConfig = void 0;
37
- var fs_1 = __importDefault(require("fs"));
38
- var schema_1 = require("./schema");
39
- var ajv_1 = __importDefault(require("ajv"));
40
- var E = __importStar(require("fp-ts/Either"));
41
- var ajv = new ajv_1.default();
42
- var validate = ajv.compile(schema_1.schema);
43
- var getConfig = function (path) {
44
- var c = JSON.parse(fs_1.default.readFileSync(path, "utf8"));
45
- if (!validate(__assign({}, c))) {
26
+ const fs_1 = __importDefault(require("fs"));
27
+ const schema_1 = require("./schema");
28
+ const ajv_1 = __importDefault(require("ajv"));
29
+ const E = __importStar(require("fp-ts/Either"));
30
+ const ajv = new ajv_1.default();
31
+ const validate = ajv.compile(schema_1.schema);
32
+ const getConfig = (path) => {
33
+ const c = JSON.parse(fs_1.default.readFileSync(path, "utf8"));
34
+ if (!validate(Object.assign({}, c))) {
46
35
  return E.left(new Error(JSON.stringify(validate.errors[0].message)));
47
36
  }
48
37
  // convert funcMatch to actual functions
49
- var processors = c.spec.processors.map(function (p) {
50
- var ref = p.ref, isFallback = p.isFallback, addr = p.addr, methods = p.methods, matchFunc = p.matchFunc;
51
- return { ref: ref, isFallback: isFallback, addr: addr, methods: methods, matchFunc: eval("(" + p.matchFunc + ")") };
38
+ const processors = c.spec.processors.map((p) => {
39
+ const { ref, isFallback, addr, methods, matchFunc } = p;
40
+ return { ref, isFallback, addr, methods, matchFunc: eval(`(${p.matchFunc})`) };
52
41
  });
53
42
  // Re-insert processors with matchFunc now as a function
54
43
  c.spec.processors = processors;
@@ -1,5 +1,4 @@
1
1
  import { ProcessorGPRCConnection } from "./types";
2
- import { ProcessorConfig } from "@routr/common";
3
2
  /**
4
3
  * Creates a connection to all the backend processors. The function will
5
4
  * fail if any of the backends is unavailable during initialization.
@@ -7,4 +6,7 @@ import { ProcessorConfig } from "@routr/common";
7
6
  * @param processors list of backend processors
8
7
  * @returns list of connections
9
8
  */
10
- export default function connectToBackendProcessors(processors: ProcessorConfig[]): Map<string, ProcessorGPRCConnection>;
9
+ export default function connectToBackend(processors: {
10
+ ref: string;
11
+ addr: string;
12
+ }[]): Map<string, ProcessorGPRCConnection>;
@@ -1,39 +1,7 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
22
- };
23
- var __values = (this && this.__values) || function(o) {
24
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
25
- if (m) return m.call(o);
26
- if (o && typeof o.length === "number") return {
27
- next: function () {
28
- if (o && i >= o.length) o = void 0;
29
- return { value: o && o[i++], done: !o };
30
- }
31
- };
32
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
33
- };
34
2
  Object.defineProperty(exports, "__esModule", { value: true });
35
- var common_1 = require("@routr/common");
36
- var grpc = require("@grpc/grpc-js");
3
+ const common_1 = require("@routr/common");
4
+ const grpc = require("@grpc/grpc-js");
37
5
  /**
38
6
  * Creates a connection to all the backend processors. The function will
39
7
  * fail if any of the backends is unavailable during initialization.
@@ -41,23 +9,12 @@ var grpc = require("@grpc/grpc-js");
41
9
  * @param processors list of backend processors
42
10
  * @returns list of connections
43
11
  */
44
- function connectToBackendProcessors(processors) {
45
- var e_1, _a;
46
- var procs = __spreadArray([], __read(processors));
47
- var connections = new Map();
48
- try {
49
- for (var procs_1 = __values(procs), procs_1_1 = procs_1.next(); !procs_1_1.done; procs_1_1 = procs_1.next()) {
50
- var processor = procs_1_1.value;
51
- connections.set(processor.ref, new common_1.PROCESSOR_OBJECT_PROTO.Processor(processor.addr, grpc.credentials.createInsecure()));
52
- }
53
- }
54
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
55
- finally {
56
- try {
57
- if (procs_1_1 && !procs_1_1.done && (_a = procs_1.return)) _a.call(procs_1);
58
- }
59
- finally { if (e_1) throw e_1.error; }
12
+ function connectToBackend(processors) {
13
+ const procs = processors ? [...processors] : [];
14
+ const connections = new Map();
15
+ for (const processor of procs) {
16
+ connections.set(processor.ref, new common_1.PROCESSOR_OBJECT_PROTO.Processor(processor.addr, grpc.credentials.createInsecure()));
60
17
  }
61
18
  return connections;
62
19
  }
63
- exports.default = connectToBackendProcessors;
20
+ exports.default = connectToBackend;
package/dist/errors.d.ts CHANGED
@@ -7,3 +7,7 @@ export declare class ProcessorUnavailableError extends Error {
7
7
  code: number;
8
8
  constructor(ref: string);
9
9
  }
10
+ export declare class MiddlewareUnavailableError extends Error {
11
+ code: number;
12
+ constructor(ref: string);
13
+ }
package/dist/errors.js CHANGED
@@ -1,21 +1,6 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ProcessorUnavailableError = exports.NotMatchingProcessorFound = void 0;
3
+ exports.MiddlewareUnavailableError = exports.ProcessorUnavailableError = exports.NotMatchingProcessorFound = void 0;
19
4
  /*
20
5
  * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
21
6
  * http://github.com/fonoster/routr
@@ -34,28 +19,31 @@ exports.ProcessorUnavailableError = exports.NotMatchingProcessorFound = void 0;
34
19
  * See the License for the specific language governing permissions and
35
20
  * limitations under the License.
36
21
  */
37
- var grpc = require("@grpc/grpc-js");
38
- var NotMatchingProcessorFound = /** @class */ (function (_super) {
39
- __extends(NotMatchingProcessorFound, _super);
40
- function NotMatchingProcessorFound(ref) {
41
- var _this = _super.call(this, "not matching processor found for request ref: " + ref) || this;
42
- _this.code = grpc.status.NOT_FOUND;
22
+ const grpc = require("@grpc/grpc-js");
23
+ class NotMatchingProcessorFound extends Error {
24
+ constructor(ref) {
25
+ super(`not matching processor found for request ref: ${ref}`);
26
+ this.code = grpc.status.NOT_FOUND;
43
27
  // Set the prototype explicitly.
44
- Object.setPrototypeOf(_this, NotMatchingProcessorFound.prototype);
45
- return _this;
28
+ Object.setPrototypeOf(this, NotMatchingProcessorFound.prototype);
46
29
  }
47
- return NotMatchingProcessorFound;
48
- }(Error));
30
+ }
49
31
  exports.NotMatchingProcessorFound = NotMatchingProcessorFound;
50
- var ProcessorUnavailableError = /** @class */ (function (_super) {
51
- __extends(ProcessorUnavailableError, _super);
52
- function ProcessorUnavailableError(ref) {
53
- var _this = _super.call(this, "processor ref = " + ref + " is unavailable") || this;
54
- _this.code = grpc.status.UNAVAILABLE;
32
+ class ProcessorUnavailableError extends Error {
33
+ constructor(ref) {
34
+ super(`processor ref = ${ref} is unavailable`);
35
+ this.code = grpc.status.UNAVAILABLE;
55
36
  // Set the prototype explicitly.
56
- Object.setPrototypeOf(_this, NotMatchingProcessorFound.prototype);
57
- return _this;
37
+ Object.setPrototypeOf(this, ProcessorUnavailableError.prototype);
58
38
  }
59
- return ProcessorUnavailableError;
60
- }(Error));
39
+ }
61
40
  exports.ProcessorUnavailableError = ProcessorUnavailableError;
41
+ class MiddlewareUnavailableError extends Error {
42
+ constructor(ref) {
43
+ super(`middleware ref = ${ref} is unavailable`);
44
+ this.code = grpc.status.UNAVAILABLE;
45
+ // Set the prototype explicitly.
46
+ Object.setPrototypeOf(this, MiddlewareUnavailableError.prototype);
47
+ }
48
+ }
49
+ exports.MiddlewareUnavailableError = MiddlewareUnavailableError;
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findProcessor = exports.filter = exports.hasMethod = void 0;
4
- var errors_1 = require("./errors");
5
- var hasMethod = function (config, request) {
6
- return config.methods.includes(request.method);
7
- };
4
+ const errors_1 = require("./errors");
5
+ const hasMethod = (config, request) => config.methods.includes(request.method);
8
6
  exports.hasMethod = hasMethod;
9
7
  // TODO: We need a way to test the matching function
10
- var filter = function (request, config) {
11
- return exports.hasMethod(config, request)
12
- && (config.isFallback || config.matchFunc(request));
13
- };
8
+ const filter = (request, config) => exports.hasMethod(config, request)
9
+ && (config.isFallback || config.matchFunc(request));
14
10
  exports.filter = filter;
15
- var findProcessor = function (list) {
16
- return function (request) {
17
- return list.find(function (config) { return exports.filter(request, config); })
18
- || new errors_1.NotMatchingProcessorFound(request.ref);
19
- };
20
- };
11
+ const findProcessor = (list) => (request) => list.find((config) => exports.filter(request, config))
12
+ || new errors_1.NotMatchingProcessorFound(request.ref);
21
13
  exports.findProcessor = findProcessor;
@@ -1,6 +1,7 @@
1
- import { MessageRequest, ProcessorConfig } from "@routr/common";
2
- import { NotMatchingProcessorFound, ProcessorUnavailableError } from "./errors";
3
- declare type CallbackErrors = NotMatchingProcessorFound | ProcessorUnavailableError | Error;
4
- declare type ProcessorCallback = (err: CallbackErrors, reponse?: MessageRequest) => void;
5
- export default function processor(configList: Array<ProcessorConfig>): (call: any, callback: ProcessorCallback) => void;
6
- export {};
1
+ import { ProcessorConfig } from "@routr/common";
2
+ import { ProcessorCallback } from "./types";
3
+ import { MiddlewareConfig } from "@routr/common/src/types";
4
+ export default function processor(params: {
5
+ processors: ProcessorConfig[];
6
+ middlewares?: MiddlewareConfig[];
7
+ }): (call: any, callback: ProcessorCallback) => void;
package/dist/processor.js CHANGED
@@ -21,31 +21,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  * See the License for the specific language governing permissions and
22
22
  * limitations under the License.
23
23
  */
24
- var find_processor_1 = require("./find_processor");
25
- var connections_1 = __importDefault(require("./connections"));
26
- var errors_1 = require("./errors");
27
- var grpc = require("@grpc/grpc-js");
28
- function processor(configList) {
29
- var connections = connections_1.default(configList);
24
+ const connections_1 = __importDefault(require("./connections"));
25
+ const run_processor_1 = require("./run_processor");
26
+ const run_middlewares_1 = require("./run_middlewares");
27
+ const logger_1 = __importDefault(require("@fonoster/logger"));
28
+ function processor(params) {
29
+ const { processors, middlewares } = params;
30
+ const procConns = connections_1.default(processors);
31
+ const middConns = connections_1.default(middlewares);
30
32
  // Upstream request and callback
31
- return function (call, callback) {
32
- var request = call.request;
33
- var matchResult = find_processor_1.findProcessor(configList)(request);
34
- if ('ref' in matchResult) {
35
- var conn = connections.get(matchResult.ref);
36
- // Connects to downstream processor
37
- conn.processMessage(request, function (err, response) {
38
- if ((err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE) {
39
- // We aument the error to indicate which processor failed
40
- callback(new errors_1.ProcessorUnavailableError(matchResult.ref));
41
- return;
42
- }
43
- callback(err, response);
44
- });
45
- }
46
- else {
47
- callback(matchResult);
33
+ return (call, callback) => {
34
+ const { request } = call;
35
+ // Messages type reponse will not be sent to middleware chain
36
+ if (request.message.message_type === 'response_type') {
37
+ return run_processor_1.runProcessor({ callback, request, processors, connections: procConns });
48
38
  }
39
+ run_middlewares_1.runMiddlewares({ callback, request, middlewares, connections: middConns })
40
+ .then((req) => {
41
+ // Since the chain was broken we need to skip the processor and return the updated request
42
+ if (req.message.message_type === "response_type") {
43
+ logger_1.default.verbose("skipped processsing request ref " + req.ref);
44
+ return callback(null, req);
45
+ }
46
+ run_processor_1.runProcessor({ callback, request: req, processors, connections: procConns });
47
+ })
48
+ .catch(callback);
49
49
  };
50
50
  }
51
51
  exports.default = processor;
@@ -0,0 +1,3 @@
1
+ import { RunMiddlewaresParams } from "./types";
2
+ import { MessageRequest } from "@routr/common";
3
+ export declare function runMiddlewares(params: RunMiddlewaresParams): Promise<MessageRequest>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.runMiddlewares = void 0;
16
+ /*
17
+ * Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
18
+ * http://github.com/fonoster/routr
19
+ *
20
+ * This file is part of Routr
21
+ *
22
+ * Licensed under the MIT License (the "License")
23
+ * you may not use this file except in compliance with
24
+ * the License. You may obtain a copy of the License at
25
+ *
26
+ * https://opensource.org/licenses/MIT
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software
29
+ * distributed under the License is distributed on an "AS IS" BASIS,
30
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ * See the License for the specific language governing permissions and
32
+ * limitations under the License.
33
+ */
34
+ const errors_1 = require("./errors");
35
+ const grpc = require("@grpc/grpc-js");
36
+ const logger_1 = __importDefault(require("@fonoster/logger"));
37
+ function processMessage(middlewareRef, conn, request) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ return new Promise((resolve, reject) => {
40
+ conn.processMessage(request, (err, response) => {
41
+ return (err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE
42
+ ? reject(new errors_1.MiddlewareUnavailableError(middlewareRef))
43
+ : resolve(response);
44
+ });
45
+ });
46
+ });
47
+ }
48
+ function runMiddlewares(params) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const { connections, request, middlewares = [] } = params;
51
+ const req = Object.assign({}, request);
52
+ return new Promise((resolve, rejects) => __awaiter(this, void 0, void 0, function* () {
53
+ for (const midd of middlewares) {
54
+ logger_1.default.verbose("forwarding request to middleware with ref => " + midd.ref);
55
+ // Get the next middleware
56
+ const conn = connections.get(midd.ref);
57
+ // Send message and re-insert response for next middleware
58
+ try {
59
+ req.message = (yield processMessage(midd.ref, conn, req)).message;
60
+ if (req.message.message_type === "response_type") {
61
+ logger_1.default.verbose("found message_type to be response_type and broke the chain");
62
+ break;
63
+ }
64
+ }
65
+ catch (e) {
66
+ rejects(e);
67
+ }
68
+ }
69
+ resolve(req);
70
+ }));
71
+ });
72
+ }
73
+ exports.runMiddlewares = runMiddlewares;
@@ -0,0 +1,2 @@
1
+ import { RunProcessorParams } from "./types";
2
+ export declare function runProcessor(params: RunProcessorParams): any;
@@ -0,0 +1,47 @@
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.runProcessor = 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 errors_1 = require("./errors");
26
+ const find_processor_1 = require("./find_processor");
27
+ const grpc = require("@grpc/grpc-js");
28
+ const logger_1 = __importDefault(require("@fonoster/logger"));
29
+ function runProcessor(params) {
30
+ const { callback, connections, processors, request } = params;
31
+ const matchResult = find_processor_1.findProcessor(processors)(request);
32
+ if ('code' in matchResult) {
33
+ return callback(matchResult);
34
+ }
35
+ logger_1.default.verbose("forwarding request to processor with ref => " + matchResult.ref);
36
+ const conn = connections.get(matchResult.ref);
37
+ // Connects to downstream processor
38
+ conn.processMessage(request, (err, response) => {
39
+ if ((err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE) {
40
+ // We augment the error to indicate which processor failed
41
+ callback(new errors_1.ProcessorUnavailableError(matchResult.ref));
42
+ return;
43
+ }
44
+ callback(err, response);
45
+ });
46
+ }
47
+ exports.runProcessor = runProcessor;
package/dist/runner.js CHANGED
@@ -22,12 +22,13 @@ 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 get_config_1 = require("./config/get_config");
27
- var result = get_config_1.getConfig(process.env.CONFIG_PATH);
25
+ const service_1 = __importDefault(require("./service"));
26
+ const get_config_1 = require("./config/get_config");
27
+ const logger_1 = __importDefault(require("@fonoster/logger"));
28
+ const result = get_config_1.getConfig(process.env.CONFIG_PATH);
28
29
  if (result._tag === 'Right') {
29
30
  service_1.default(result.right);
30
31
  }
31
32
  else {
32
- console.log(result.left);
33
+ logger_1.default.error(result.left);
33
34
  }
package/dist/service.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var common_1 = require("@routr/common");
4
- var util_1 = require("./util");
3
+ const common_1 = require("@routr/common");
4
+ const util_1 = require("./util");
5
5
  function MessageDispatcher(config) {
6
- var bindAddr = config.bindAddr, processors = config.processors;
7
- common_1.createService(util_1.getServiceInfo(bindAddr, processors));
6
+ const { bindAddr, processors, middlewares } = config;
7
+ common_1.createService(util_1.getServiceInfo(bindAddr, { processors, middlewares }));
8
8
  }
9
9
  exports.default = MessageDispatcher;
package/dist/types.d.ts CHANGED
@@ -1,8 +1,25 @@
1
- import { ProcessorConfig } from "@routr/common";
1
+ import { MessageRequest, ProcessorConfig } from "@routr/common";
2
+ import { MiddlewareConfig } from "@routr/common/src/types";
3
+ import { NotMatchingProcessorFound, ProcessorUnavailableError } from "./errors";
2
4
  export interface MessageDispatcherConfig {
3
5
  bindAddr: string;
4
- processors: Array<ProcessorConfig>;
6
+ processors: ProcessorConfig[];
7
+ middlewares: MiddlewareConfig[];
5
8
  }
6
9
  export interface ProcessorGPRCConnection {
7
10
  processMessage: (request: unknown, callback: Function) => void;
8
11
  }
12
+ export declare type CallbackErrors = NotMatchingProcessorFound | ProcessorUnavailableError | Error;
13
+ export declare type ProcessorCallback = (err: CallbackErrors, reponse?: MessageRequest) => void;
14
+ export interface RunProcessorParams {
15
+ callback: Function;
16
+ connections: Map<string, ProcessorGPRCConnection>;
17
+ processors: ProcessorConfig[];
18
+ request: MessageRequest;
19
+ }
20
+ export interface RunMiddlewaresParams {
21
+ callback: Function;
22
+ connections: Map<string, ProcessorGPRCConnection>;
23
+ middlewares: MiddlewareConfig[];
24
+ request: MessageRequest;
25
+ }
package/dist/util.d.ts CHANGED
@@ -1,2 +1,6 @@
1
1
  import { ProcessorConfig, ServiceInfo } from "@routr/common";
2
- export declare function getServiceInfo(bindAddr: string, processors: ProcessorConfig[]): ServiceInfo;
2
+ import { MiddlewareConfig } from "@routr/common/src/types";
3
+ export declare function getServiceInfo(bindAddr: string, backends: {
4
+ middlewares: MiddlewareConfig[];
5
+ processors: ProcessorConfig[];
6
+ }): ServiceInfo;
package/dist/util.js CHANGED
@@ -22,15 +22,15 @@ exports.getServiceInfo = void 0;
22
22
  * See the License for the specific language governing permissions and
23
23
  * limitations under the License.
24
24
  */
25
- var processor_1 = __importDefault(require("./processor"));
26
- var common_1 = require("@routr/common");
27
- function getServiceInfo(bindAddr, processors) {
25
+ const processor_1 = __importDefault(require("./processor"));
26
+ const common_1 = require("@routr/common");
27
+ function getServiceInfo(bindAddr, backends) {
28
28
  return {
29
29
  name: "dispatcher",
30
- bindAddr: bindAddr,
30
+ bindAddr,
31
31
  service: common_1.PROCESSOR_OBJECT_PROTO.Processor.service,
32
32
  handlers: {
33
- processMessage: processor_1.default(processors)
33
+ processMessage: processor_1.default(backends)
34
34
  }
35
35
  };
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/dispatcher",
3
- "version": "2.0.5-alpha.2",
3
+ "version": "2.0.5-alpha.3",
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",
@@ -25,7 +25,7 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "@routr/common": "^2.0.5-alpha.2",
28
+ "@routr/common": "^2.0.5-alpha.3",
29
29
  "ajv": "^6.12.6",
30
30
  "fp-ts": "^2.11.8"
31
31
  },
@@ -36,5 +36,5 @@
36
36
  "bugs": {
37
37
  "url": "https://github.com/fonoster/routr/issues"
38
38
  },
39
- "gitHead": "3570106be9a96cb6672de4a850a377bfa7d9bb3e"
39
+ "gitHead": "7d942466133a03f4bcfe0dc100f1a922b3ed14ad"
40
40
  }