@routr/location 2.0.8-alpha.2 → 2.0.8-alpha.22
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/client.d.ts +2 -2
- package/dist/client.js +3 -3
- package/dist/config/get_config.d.ts +2 -2
- package/dist/config/get_config.js +7 -25
- package/dist/config/schema.d.ts +0 -20
- package/dist/config/schema.js +3 -23
- package/dist/errors.d.ts +0 -21
- package/dist/errors.js +1 -27
- package/dist/helper.js +5 -3
- package/dist/location.d.ts +2 -4
- package/dist/location.js +30 -22
- package/dist/service.js +3 -4
- package/dist/types.d.ts +11 -14
- package/dist/types.js +6 -11
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export default class Location implements ILocationService {
|
|
|
31
31
|
*
|
|
32
32
|
* @param {FindRoutesResponse} request - Request to find routes
|
|
33
33
|
* @param {string} request.aor - AOR of the route
|
|
34
|
-
* @param {Map<string, string>} request.labels - Optional Route labels
|
|
35
|
-
* @param {
|
|
34
|
+
* @param {Map<string, string>} request.labels - Optional Route labels (reserved for future use)
|
|
35
|
+
* @param {object} request.backend - Optional Route backend (reserved for future use)
|
|
36
36
|
* @return {Promise<void>}
|
|
37
37
|
*/
|
|
38
38
|
findRoutes(request: FindRoutesRequest): Promise<Route[]>;
|
package/dist/client.js
CHANGED
|
@@ -38,7 +38,7 @@ const container = (self, request, name) => {
|
|
|
38
38
|
return new Promise((resolve, reject) => {
|
|
39
39
|
self.location[name](request, (err, response) => {
|
|
40
40
|
if ((err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE) {
|
|
41
|
-
return reject(new common_1.ServiceUnavailableError(self.config.addr));
|
|
41
|
+
return reject(new common_1.CommonErrors.ServiceUnavailableError(self.config.addr));
|
|
42
42
|
}
|
|
43
43
|
resolve(response);
|
|
44
44
|
});
|
|
@@ -75,8 +75,8 @@ class Location {
|
|
|
75
75
|
*
|
|
76
76
|
* @param {FindRoutesResponse} request - Request to find routes
|
|
77
77
|
* @param {string} request.aor - AOR of the route
|
|
78
|
-
* @param {Map<string, string>} request.labels - Optional Route labels
|
|
79
|
-
* @param {
|
|
78
|
+
* @param {Map<string, string>} request.labels - Optional Route labels (reserved for future use)
|
|
79
|
+
* @param {object} request.backend - Optional Route backend (reserved for future use)
|
|
80
80
|
* @return {Promise<void>}
|
|
81
81
|
*/
|
|
82
82
|
findRoutes(request) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { LocationConfig } from "../types";
|
|
2
2
|
import * as E from "fp-ts/Either";
|
|
3
|
-
import {
|
|
4
|
-
export declare const getConfig: (path: string) => E.Either<
|
|
3
|
+
import { InvalidSchemaConfiguration } from "../errors";
|
|
4
|
+
export declare const getConfig: (path: string) => E.Either<InvalidSchemaConfiguration, LocationConfig>;
|
|
@@ -46,47 +46,29 @@ exports.getConfig = void 0;
|
|
|
46
46
|
* limitations under the License.
|
|
47
47
|
*/
|
|
48
48
|
const types_1 = require("../types");
|
|
49
|
-
const
|
|
49
|
+
const common_1 = require("@routr/common");
|
|
50
50
|
const schema_1 = require("./schema");
|
|
51
51
|
const ajv_1 = __importDefault(require("ajv"));
|
|
52
52
|
const E = __importStar(require("fp-ts/Either"));
|
|
53
53
|
const errors_1 = require("../errors");
|
|
54
54
|
const ajv = new ajv_1.default();
|
|
55
55
|
const validate = ajv.compile(schema_1.schema);
|
|
56
|
-
const hasBadCombiniation = (backends) => backends.some((b) => b.balancingAlgorithm === types_1.LB_ALGORITHM.ROUND_ROBIN && b.withSessionAffinity);
|
|
57
|
-
const hasBadAlgorithm = (backends) => backends.some((b) => b.balancingAlgorithm !== types_1.LB_ALGORITHM.ROUND_ROBIN &&
|
|
58
|
-
b.balancingAlgorithm !== types_1.LB_ALGORITHM.LEAST_SESSIONS);
|
|
59
56
|
const getConfig = (path) => {
|
|
60
57
|
var _a, _b, _c;
|
|
61
|
-
const c =
|
|
58
|
+
const c = common_1.Helper.readConfigFile(path);
|
|
62
59
|
if (!validate(Object.assign({}, c))) {
|
|
63
60
|
return E.left(new errors_1.InvalidSchemaConfiguration(JSON.stringify(validate.errors[0].message)));
|
|
64
61
|
}
|
|
65
62
|
const config = c.spec;
|
|
66
|
-
if (config.
|
|
67
|
-
config.backends.map((b) => {
|
|
68
|
-
// Setting round-robin by default
|
|
69
|
-
b.balancingAlgorithm = b.balancingAlgorithm
|
|
70
|
-
? b.balancingAlgorithm
|
|
71
|
-
: types_1.LB_ALGORITHM.ROUND_ROBIN;
|
|
72
|
-
return b;
|
|
73
|
-
});
|
|
74
|
-
if (hasBadCombiniation(config.backends)) {
|
|
75
|
-
return E.left(new errors_1.BadAlgorithmAndAffinityCombination());
|
|
76
|
-
}
|
|
77
|
-
if (hasBadAlgorithm(config.backends)) {
|
|
78
|
-
return E.left(new errors_1.InvalidLoadBalancerAlgorithm());
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!((_a = config === null || config === void 0 ? void 0 : config.cache) === null || _a === void 0 ? void 0 : _a.provider)) {
|
|
63
|
+
if (!((_a = config.cache) === null || _a === void 0 ? void 0 : _a.provider)) {
|
|
82
64
|
config.cache = {
|
|
83
|
-
provider: types_1.
|
|
65
|
+
provider: types_1.CacheProvider.MEMORY
|
|
84
66
|
};
|
|
85
67
|
}
|
|
86
|
-
if (((_b = config
|
|
87
|
-
!((_c = config
|
|
68
|
+
if (((_b = config.cache) === null || _b === void 0 ? void 0 : _b.provider) === types_1.CacheProvider.REDIS &&
|
|
69
|
+
!((_c = config.cache) === null || _c === void 0 ? void 0 : _c.parameters)) {
|
|
88
70
|
config.cache = {
|
|
89
|
-
provider: types_1.
|
|
71
|
+
provider: types_1.CacheProvider.REDIS,
|
|
90
72
|
parameters: "host=localhost,port=6379"
|
|
91
73
|
};
|
|
92
74
|
}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -34,26 +34,6 @@ export declare const schema: {
|
|
|
34
34
|
};
|
|
35
35
|
required: string[];
|
|
36
36
|
};
|
|
37
|
-
backends: {
|
|
38
|
-
description: string;
|
|
39
|
-
type: string;
|
|
40
|
-
items: {
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
properties: {
|
|
44
|
-
ref: {
|
|
45
|
-
type: string;
|
|
46
|
-
};
|
|
47
|
-
balancingAlgorithm: {
|
|
48
|
-
enum: string[];
|
|
49
|
-
};
|
|
50
|
-
withSessionAffinity: {
|
|
51
|
-
description: string;
|
|
52
|
-
type: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
required: string[];
|
|
56
|
-
};
|
|
57
37
|
};
|
|
58
38
|
};
|
|
59
39
|
};
|
package/dist/config/schema.js
CHANGED
|
@@ -29,7 +29,7 @@ exports.schema = {
|
|
|
29
29
|
enum: ["Location", "location"]
|
|
30
30
|
},
|
|
31
31
|
apiVersion: {
|
|
32
|
-
enum: ["v2draft1"]
|
|
32
|
+
enum: ["v2draft1", "v2"]
|
|
33
33
|
},
|
|
34
34
|
metadata: {
|
|
35
35
|
description: "Resource metadata",
|
|
@@ -47,36 +47,16 @@ exports.schema = {
|
|
|
47
47
|
type: "object",
|
|
48
48
|
properties: {
|
|
49
49
|
provider: {
|
|
50
|
-
enum: ["memory", "redis"]
|
|
50
|
+
enum: ["Memory", "Redis", "memory", "redis"]
|
|
51
51
|
},
|
|
52
52
|
parameters: {
|
|
53
53
|
type: "string"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
required: ["provider"]
|
|
57
|
-
},
|
|
58
|
-
backends: {
|
|
59
|
-
description: "Optional SIP backends",
|
|
60
|
-
type: "array",
|
|
61
|
-
items: {
|
|
62
|
-
type: "object"
|
|
63
|
-
},
|
|
64
|
-
properties: {
|
|
65
|
-
ref: {
|
|
66
|
-
type: "string"
|
|
67
|
-
},
|
|
68
|
-
balancingAlgorithm: {
|
|
69
|
-
enum: ["round-robin", "least-sessions"]
|
|
70
|
-
},
|
|
71
|
-
withSessionAffinity: {
|
|
72
|
-
description: "Optional session affinity",
|
|
73
|
-
type: "boolean"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
required: ["ref"]
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
59
|
}
|
|
80
60
|
},
|
|
81
|
-
required: ["kind", "
|
|
61
|
+
required: ["apiVersion", "kind", "metadata", "spec"]
|
|
82
62
|
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as grpc from "@grpc/grpc-js";
|
|
2
2
|
export type LocationError = UnsupportedSchema | NotRoutesFoundForAOR;
|
|
3
|
-
export type InvalidConfiguration = BadAlgorithmAndAffinityCombination | InvalidSchemaConfiguration;
|
|
4
3
|
/**
|
|
5
4
|
* Error thrown when the location service returns an unsupported schema.
|
|
6
5
|
*/
|
|
@@ -37,23 +36,3 @@ export declare class InvalidSchemaConfiguration extends Error {
|
|
|
37
36
|
*/
|
|
38
37
|
constructor(msg: string);
|
|
39
38
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Error thrown when the location finds incompatible algorithm and session affinity.
|
|
42
|
-
*/
|
|
43
|
-
export declare class BadAlgorithmAndAffinityCombination extends Error {
|
|
44
|
-
code: grpc.status;
|
|
45
|
-
/**
|
|
46
|
-
* Create a new BadAlgorithmAndAffinityCombination error.
|
|
47
|
-
*/
|
|
48
|
-
constructor();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Error thrown when the location finds an invalid balancing algorithm.
|
|
52
|
-
*/
|
|
53
|
-
export declare class InvalidLoadBalancerAlgorithm extends Error {
|
|
54
|
-
code: grpc.status;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new InvalidLoadBalancerAlgorithm error.
|
|
57
|
-
*/
|
|
58
|
-
constructor();
|
|
59
|
-
}
|
package/dist/errors.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.InvalidSchemaConfiguration = exports.NotRoutesFoundForAOR = exports.UnsupportedSchema = void 0;
|
|
27
27
|
/*
|
|
28
28
|
* Copyright (C) 2022 by Fonoster Inc (https://fonoster.com)
|
|
29
29
|
* http://github.com/fonoster/routr
|
|
@@ -92,29 +92,3 @@ class InvalidSchemaConfiguration extends Error {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
exports.InvalidSchemaConfiguration = InvalidSchemaConfiguration;
|
|
95
|
-
/**
|
|
96
|
-
* Error thrown when the location finds incompatible algorithm and session affinity.
|
|
97
|
-
*/
|
|
98
|
-
class BadAlgorithmAndAffinityCombination extends Error {
|
|
99
|
-
/**
|
|
100
|
-
* Create a new BadAlgorithmAndAffinityCombination error.
|
|
101
|
-
*/
|
|
102
|
-
constructor() {
|
|
103
|
-
super("session affinity can not be combined with round-robin load balancing");
|
|
104
|
-
Object.setPrototypeOf(this, BadAlgorithmAndAffinityCombination.prototype);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.BadAlgorithmAndAffinityCombination = BadAlgorithmAndAffinityCombination;
|
|
108
|
-
/**
|
|
109
|
-
* Error thrown when the location finds an invalid balancing algorithm.
|
|
110
|
-
*/
|
|
111
|
-
class InvalidLoadBalancerAlgorithm extends Error {
|
|
112
|
-
/**
|
|
113
|
-
* Create a new InvalidLoadBalancerAlgorithm error.
|
|
114
|
-
*/
|
|
115
|
-
constructor() {
|
|
116
|
-
super("found invalid load balancing algorithm. must be round-robin or least-sessions");
|
|
117
|
-
Object.setPrototypeOf(this, BadAlgorithmAndAffinityCombination.prototype);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.InvalidLoadBalancerAlgorithm = InvalidLoadBalancerAlgorithm;
|
package/dist/helper.js
CHANGED
|
@@ -28,21 +28,23 @@ const processor_1 = require("@routr/processor");
|
|
|
28
28
|
// Also consider: https://github.com/fonoster/routr/blob/ee5d339888344013939d06c734385f17f0cd75c2/mod/registrar/utils.js#L116
|
|
29
29
|
// and https://github.com/fonoster/routr/blob/ee5d339888344013939d06c734385f17f0cd75c2/mod/registrar/utils.js#L131
|
|
30
30
|
const createRoute = (request) => {
|
|
31
|
+
var _a;
|
|
31
32
|
const uri = request.message.contact.address.uri;
|
|
32
33
|
const sessionCount = processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT)
|
|
33
34
|
? parseInt(processor_1.Extensions.getHeaderValue(request, common_1.CommonTypes.ExtraHeader.SESSION_COUNT))
|
|
34
35
|
: -1;
|
|
35
|
-
const egressListeningPoint = common_1.Helper.getListeningPoint(request, uri.transportParam.toLowerCase());
|
|
36
36
|
return {
|
|
37
37
|
edgePortRef: request.edgePortRef,
|
|
38
38
|
user: uri.user,
|
|
39
39
|
host: uri.host,
|
|
40
40
|
port: uri.port,
|
|
41
|
-
transport: uri.transportParam.
|
|
41
|
+
transport: (_a = uri.transportParam) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
42
42
|
registeredOn: Date.now(),
|
|
43
43
|
sessionCount,
|
|
44
44
|
expires: processor_1.Target.getTargetExpires(request),
|
|
45
|
-
|
|
45
|
+
listeningPoints: request.listeningPoints,
|
|
46
|
+
localnets: request.localnets,
|
|
47
|
+
externalAddrs: request.externalAddrs
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
50
|
exports.createRoute = createRoute;
|
package/dist/location.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { AddRouteRequest,
|
|
1
|
+
import { AddRouteRequest, FindRoutesRequest, ILocationService, ILocatorStore, RemoveRoutesRequest } from "./types";
|
|
2
2
|
import { Route } from "@routr/common";
|
|
3
3
|
/**
|
|
4
4
|
* A locator store that uses the location service to find routes for AORs.
|
|
5
5
|
*/
|
|
6
6
|
export default class Location implements ILocationService {
|
|
7
7
|
private store;
|
|
8
|
-
private backends;
|
|
9
8
|
private rrCount;
|
|
10
|
-
private affinityStore;
|
|
11
9
|
/**
|
|
12
10
|
* Creates a new Location service. Should fail if any backend has sessionAffinity and round-robin
|
|
13
11
|
*
|
|
14
12
|
* @param {ILocatorStore} store - The store to use for the location service
|
|
15
13
|
* @param {Map<string, Backend>} backends - The backends to use for the location service
|
|
16
14
|
*/
|
|
17
|
-
constructor(store: ILocatorStore
|
|
15
|
+
constructor(store: ILocatorStore);
|
|
18
16
|
/** @inheritdoc */
|
|
19
17
|
addRoute(request: AddRouteRequest): Promise<void>;
|
|
20
18
|
/** @inheritdoc */
|
package/dist/location.js
CHANGED
|
@@ -28,7 +28,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
* limitations under the License.
|
|
29
29
|
*/
|
|
30
30
|
const errors_1 = require("./errors");
|
|
31
|
-
const
|
|
31
|
+
const common_1 = require("@routr/common");
|
|
32
32
|
const utils_1 = require("./utils");
|
|
33
33
|
var AOR_SCHEME;
|
|
34
34
|
(function (AOR_SCHEME) {
|
|
@@ -45,12 +45,9 @@ class Location {
|
|
|
45
45
|
* @param {ILocatorStore} store - The store to use for the location service
|
|
46
46
|
* @param {Map<string, Backend>} backends - The backends to use for the location service
|
|
47
47
|
*/
|
|
48
|
-
constructor(store
|
|
48
|
+
constructor(store) {
|
|
49
49
|
this.store = store;
|
|
50
|
-
this.backends = backends;
|
|
51
50
|
this.rrCount = new Map();
|
|
52
|
-
this.affinityStore = new Map();
|
|
53
|
-
this.backends.forEach((value, key) => this.rrCount.set(key, 0));
|
|
54
51
|
}
|
|
55
52
|
/** @inheritdoc */
|
|
56
53
|
addRoute(request) {
|
|
@@ -64,21 +61,29 @@ class Location {
|
|
|
64
61
|
findRoutes(request) {
|
|
65
62
|
var _a;
|
|
66
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
|
|
64
|
+
let routes = yield this.store.get(request.callId);
|
|
65
|
+
if (routes.length > 0) {
|
|
66
|
+
return routes;
|
|
67
|
+
}
|
|
68
|
+
routes = request.labels
|
|
68
69
|
? (yield this.store.get(request.aor)).filter((0, utils_1.filterOnlyMatchingLabels)(request.labels))
|
|
69
70
|
: (_a = (yield this.store.get(request.aor))) !== null && _a !== void 0 ? _a : [];
|
|
70
71
|
if (request.aor.startsWith(AOR_SCHEME.SIP)) {
|
|
72
|
+
// Set call to the last route
|
|
73
|
+
this.store.put(request.callId, routes[0]);
|
|
71
74
|
return routes;
|
|
72
75
|
}
|
|
73
76
|
else if (request.aor.startsWith(AOR_SCHEME.BACKEND)) {
|
|
74
|
-
const backend =
|
|
75
|
-
if (!backend) {
|
|
76
|
-
throw new errors_1.NotRoutesFoundForAOR(request.aor);
|
|
77
|
-
}
|
|
77
|
+
const { backend } = request;
|
|
78
78
|
// If it has not affinity sesssion then get next
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const r =
|
|
80
|
+
// Falls back to round-robin if no session affinity ref is provided
|
|
81
|
+
backend.withSessionAffinity && request.sessionAffinityRef
|
|
82
|
+
? [yield this.nextWithAffinity(routes, request.sessionAffinityRef)]
|
|
81
83
|
: [this.next(routes, backend)];
|
|
84
|
+
// Next time we will get the route with callId
|
|
85
|
+
this.store.put(request.callId, r[0]);
|
|
86
|
+
return r;
|
|
82
87
|
}
|
|
83
88
|
throw new errors_1.UnsupportedSchema(request.aor);
|
|
84
89
|
});
|
|
@@ -89,11 +94,12 @@ class Location {
|
|
|
89
94
|
}
|
|
90
95
|
// eslint-disable-next-line require-jsdoc
|
|
91
96
|
next(routes, backend) {
|
|
92
|
-
|
|
97
|
+
var _a;
|
|
98
|
+
if (backend.balancingAlgorithm === common_1.CommonTypes.LoadBalancingAlgorithm.LEAST_SESSIONS) {
|
|
93
99
|
return routes.sort((r1, r2) => r1.sessionCount - r2.sessionCount)[0];
|
|
94
100
|
}
|
|
95
101
|
// Continues using round-robin
|
|
96
|
-
const nextPosition = this.rrCount.get(`${AOR_SCHEME.BACKEND}${backend.ref}`);
|
|
102
|
+
const nextPosition = (_a = this.rrCount.get(`${AOR_SCHEME.BACKEND}${backend.ref}`)) !== null && _a !== void 0 ? _a : 0;
|
|
97
103
|
const result = routes[nextPosition];
|
|
98
104
|
if (nextPosition >= routes.length - 1) {
|
|
99
105
|
// Restarting round-robin counter
|
|
@@ -106,14 +112,16 @@ class Location {
|
|
|
106
112
|
}
|
|
107
113
|
// Backend with session affinity does not support round-robin
|
|
108
114
|
// eslint-disable-next-line require-jsdoc
|
|
109
|
-
nextWithAffinity(routes,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
nextWithAffinity(routes, sessionAffinityHeader) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const route = yield this.store.get(sessionAffinityHeader);
|
|
118
|
+
if (route.length > 0) {
|
|
119
|
+
return route[0];
|
|
120
|
+
}
|
|
121
|
+
const r = routes.sort((r1, r2) => r1.sessionCount - r2.sessionCount)[0];
|
|
122
|
+
this.store.put(sessionAffinityHeader, r);
|
|
123
|
+
return r;
|
|
124
|
+
});
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
exports.default = Location;
|
package/dist/service.js
CHANGED
|
@@ -36,17 +36,16 @@ const allowedParameters = ["host", "port", "username", "password", "secure"];
|
|
|
36
36
|
* @param {LocationConfig} config - Service configuration
|
|
37
37
|
*/
|
|
38
38
|
function LocationService(config) {
|
|
39
|
+
var _a;
|
|
39
40
|
const { bindAddr, cache } = config;
|
|
40
41
|
let store;
|
|
41
|
-
if (cache.provider === types_1.
|
|
42
|
+
if (((_a = cache.provider) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === types_1.CacheProvider.REDIS) {
|
|
42
43
|
store = new redis_store_1.default((0, utils_1.configFromString)(cache.parameters, allowedParameters));
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
store = new memory_store_1.default();
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
config.backends.forEach((b) => backends.set(`backend:${b.ref}`, b));
|
|
49
|
-
(0, common_1.createService)((0, utils_1.getServiceInfo)(bindAddr, new location_1.default(store, backends)));
|
|
48
|
+
(0, common_1.createService)((0, utils_1.getServiceInfo)(bindAddr, new location_1.default(store)));
|
|
50
49
|
logger.info(`using ${cache.provider} as cache provider`);
|
|
51
50
|
}
|
|
52
51
|
exports.default = LocationService;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { Route } from "@routr/common";
|
|
2
|
-
export declare enum LB_ALGORITHM {
|
|
3
|
-
ROUND_ROBIN = "round-robin",
|
|
4
|
-
LEAST_SESSIONS = "least-sessions"
|
|
5
|
-
}
|
|
6
|
-
export declare enum CACHE_PROVIDER {
|
|
7
|
-
MEMORY = "memory",
|
|
8
|
-
REDIS = "redis"
|
|
9
|
-
}
|
|
1
|
+
import { Route, CommonTypes as CT } from "@routr/common";
|
|
10
2
|
export interface ILocationService {
|
|
11
3
|
addRoute(request: AddRouteRequest): Promise<void>;
|
|
12
4
|
findRoutes(request: FindRoutesRequest): Promise<Route[]>;
|
|
@@ -23,8 +15,10 @@ export interface AddRouteRequest {
|
|
|
23
15
|
}
|
|
24
16
|
export interface FindRoutesRequest {
|
|
25
17
|
aor: string;
|
|
26
|
-
|
|
18
|
+
callId: string;
|
|
27
19
|
sessionAffinityRef?: string;
|
|
20
|
+
backend?: Backend;
|
|
21
|
+
labels?: Map<string, string>;
|
|
28
22
|
}
|
|
29
23
|
export interface FindRoutesResponse {
|
|
30
24
|
routes: Array<Route>;
|
|
@@ -34,14 +28,17 @@ export interface RemoveRoutesRequest {
|
|
|
34
28
|
}
|
|
35
29
|
export interface Backend {
|
|
36
30
|
ref: string;
|
|
37
|
-
balancingAlgorithm
|
|
38
|
-
withSessionAffinity
|
|
31
|
+
balancingAlgorithm: CT.LoadBalancingAlgorithm;
|
|
32
|
+
withSessionAffinity: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare enum CacheProvider {
|
|
35
|
+
MEMORY = "MEMORY",
|
|
36
|
+
REDIS = "REDIS"
|
|
39
37
|
}
|
|
40
38
|
export interface LocationConfig {
|
|
41
39
|
bindAddr: string;
|
|
42
|
-
backends?: Backend[];
|
|
43
40
|
cache?: {
|
|
44
|
-
provider:
|
|
41
|
+
provider: CacheProvider;
|
|
45
42
|
parameters?: string;
|
|
46
43
|
};
|
|
47
44
|
}
|
package/dist/types.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})(
|
|
9
|
-
var CACHE_PROVIDER;
|
|
10
|
-
(function (CACHE_PROVIDER) {
|
|
11
|
-
CACHE_PROVIDER["MEMORY"] = "memory";
|
|
12
|
-
CACHE_PROVIDER["REDIS"] = "redis";
|
|
13
|
-
})(CACHE_PROVIDER = exports.CACHE_PROVIDER || (exports.CACHE_PROVIDER = {}));
|
|
3
|
+
exports.CacheProvider = void 0;
|
|
4
|
+
var CacheProvider;
|
|
5
|
+
(function (CacheProvider) {
|
|
6
|
+
CacheProvider["MEMORY"] = "MEMORY";
|
|
7
|
+
CacheProvider["REDIS"] = "REDIS";
|
|
8
|
+
})(CacheProvider = exports.CacheProvider || (exports.CacheProvider = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@routr/location",
|
|
3
|
-
"version": "2.0.8-alpha.
|
|
3
|
+
"version": "2.0.8-alpha.22",
|
|
4
4
|
"description": "Creates and maintains a list of routes to all registered endpoints",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/routr#readme",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@fonoster/logger": "0.3.18",
|
|
29
|
-
"@grpc/grpc-js": "^1.
|
|
29
|
+
"@grpc/grpc-js": "^1.8.4",
|
|
30
30
|
"@opentelemetry/api": "^1.0.4",
|
|
31
31
|
"@opentelemetry/exporter-jaeger": "^1.0.4",
|
|
32
32
|
"@opentelemetry/instrumentation": "^0.27.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@opentelemetry/sdk-trace-base": "^1.0.4",
|
|
36
36
|
"@opentelemetry/sdk-trace-node": "^1.0.4",
|
|
37
37
|
"@opentelemetry/semantic-conventions": "^1.0.4",
|
|
38
|
-
"@routr/common": "^2.0.8-alpha.
|
|
39
|
-
"@routr/processor": "^2.0.8-alpha.
|
|
38
|
+
"@routr/common": "^2.0.8-alpha.22",
|
|
39
|
+
"@routr/processor": "^2.0.8-alpha.22",
|
|
40
40
|
"ajv": "^6.12.6",
|
|
41
41
|
"fp-ts": "^2.11.8",
|
|
42
42
|
"redis": "^4.0.4"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"bugs": {
|
|
49
49
|
"url": "https://github.com/fonoster/routr/issues"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "7c1e14c20e077f817605be62cf61a68904583bb8"
|
|
52
52
|
}
|