@routr/location 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/client.d.ts +47 -0
- package/dist/client.js +102 -0
- package/dist/config/get_config.d.ts +1 -1
- package/dist/config/get_config.js +38 -35
- package/dist/config/schema.d.ts +13 -10
- package/dist/config/schema.js +48 -45
- package/dist/errors.d.ts +37 -1
- package/dist/errors.js +88 -59
- package/dist/helper.d.ts +2 -0
- package/dist/helper.js +28 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +55 -0
- package/dist/location.d.ts +26 -0
- package/dist/location.js +118 -0
- package/dist/memory_store.d.ts +15 -1
- package/dist/memory_store.js +37 -48
- package/dist/redis_store.d.ts +21 -0
- package/dist/redis_store.js +99 -0
- package/dist/runner.js +12 -7
- package/dist/service.d.ts +5 -0
- package/dist/service.js +44 -6
- package/dist/tracer.d.ts +7 -0
- package/dist/tracer.js +53 -0
- package/dist/types.d.ts +19 -17
- package/dist/types.js +6 -19
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +78 -98
- package/package.json +18 -6
- package/dist/locator.d.ts +0 -13
- package/dist/locator.js +0 -152
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AddRouteRequest, FindRoutesRequest, ILocationService, RemoveRoutesRequest } from "./types";
|
|
2
|
+
import { Route } from "@routr/common";
|
|
3
|
+
/**
|
|
4
|
+
* Location client
|
|
5
|
+
*/
|
|
6
|
+
export default class Location implements ILocationService {
|
|
7
|
+
location: any;
|
|
8
|
+
config: {
|
|
9
|
+
addr: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Location client.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} config - Location client config
|
|
15
|
+
* @param {string} config.addr - Location service address
|
|
16
|
+
*/
|
|
17
|
+
constructor(config: {
|
|
18
|
+
addr: string;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Add a route to the location service.
|
|
22
|
+
*
|
|
23
|
+
* @param {AddRouteRequest} request - Add route request
|
|
24
|
+
* @param {string} request.aor - AOR of the route
|
|
25
|
+
* @param {Route} request.route - Route to add
|
|
26
|
+
* @return {Promise<void>}
|
|
27
|
+
*/
|
|
28
|
+
addRoute(request: AddRouteRequest): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Add a route to the location service.
|
|
31
|
+
*
|
|
32
|
+
* @param {FindRoutesResponse} request - Request to find routes
|
|
33
|
+
* @param {string} request.aor - AOR of the route
|
|
34
|
+
* @param {Map<string, string>} request.labels - Optional Route labels
|
|
35
|
+
* @param {string} request.sessionAffinityRef - Optiona session affinity ref
|
|
36
|
+
* @return {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
findRoutes(request: FindRoutesRequest): Promise<Route[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Add a route to the location service.
|
|
41
|
+
*
|
|
42
|
+
* @param {RemoveRoutesRequest} request - Remove routes request
|
|
43
|
+
* @param {string} request.aor - AOR of the route
|
|
44
|
+
* @return {Promise<void>}
|
|
45
|
+
*/
|
|
46
|
+
removeRoutes(request: RemoveRoutesRequest): Promise<void>;
|
|
47
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const common_1 = require("@routr/common");
|
|
36
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
37
|
+
const container = (self, request, name) => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
self.location[name](request, (err, response) => {
|
|
40
|
+
if ((err === null || err === void 0 ? void 0 : err.code) === grpc.status.UNAVAILABLE) {
|
|
41
|
+
return reject(new common_1.ServiceUnavailableError(self.config.addr));
|
|
42
|
+
}
|
|
43
|
+
resolve(response);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Location client
|
|
49
|
+
*/
|
|
50
|
+
class Location {
|
|
51
|
+
/**
|
|
52
|
+
* Create a new Location client.
|
|
53
|
+
*
|
|
54
|
+
* @param {object} config - Location client config
|
|
55
|
+
* @param {string} config.addr - Location service address
|
|
56
|
+
*/
|
|
57
|
+
constructor(config) {
|
|
58
|
+
this.config = config;
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
this.location = new common_1.LOCATION_OBJECT_PROTO.Location(config.addr, grpc.credentials.createInsecure());
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add a route to the location service.
|
|
64
|
+
*
|
|
65
|
+
* @param {AddRouteRequest} request - Add route request
|
|
66
|
+
* @param {string} request.aor - AOR of the route
|
|
67
|
+
* @param {Route} request.route - Route to add
|
|
68
|
+
* @return {Promise<void>}
|
|
69
|
+
*/
|
|
70
|
+
addRoute(request) {
|
|
71
|
+
return container(this, request, this.addRoute.name);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Add a route to the location service.
|
|
75
|
+
*
|
|
76
|
+
* @param {FindRoutesResponse} request - Request to find routes
|
|
77
|
+
* @param {string} request.aor - AOR of the route
|
|
78
|
+
* @param {Map<string, string>} request.labels - Optional Route labels
|
|
79
|
+
* @param {string} request.sessionAffinityRef - Optiona session affinity ref
|
|
80
|
+
* @return {Promise<void>}
|
|
81
|
+
*/
|
|
82
|
+
findRoutes(request) {
|
|
83
|
+
var _a;
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
return (
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
((_a = ((yield container(this, request, this.findRoutes.name)))) === null || _a === void 0 ? void 0 : _a.routes) ||
|
|
88
|
+
[]);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Add a route to the location service.
|
|
93
|
+
*
|
|
94
|
+
* @param {RemoveRoutesRequest} request - Remove routes request
|
|
95
|
+
* @param {string} request.aor - AOR of the route
|
|
96
|
+
* @return {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
removeRoutes(request) {
|
|
99
|
+
return container(this, request, this.removeRoutes.name);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.default = Location;
|
|
@@ -1,18 +1,11 @@
|
|
|
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
|
-
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);
|
|
16
9
|
}) : (function(o, m, k, k2) {
|
|
17
10
|
if (k2 === undefined) k2 = k;
|
|
18
11
|
o[k2] = m[k];
|
|
@@ -52,41 +45,51 @@ exports.getConfig = void 0;
|
|
|
52
45
|
* See the License for the specific language governing permissions and
|
|
53
46
|
* limitations under the License.
|
|
54
47
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
const types_1 = require("../types");
|
|
49
|
+
const fs_1 = __importDefault(require("fs"));
|
|
50
|
+
const schema_1 = require("./schema");
|
|
51
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
52
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
53
|
+
const errors_1 = require("../errors");
|
|
54
|
+
const ajv = new ajv_1.default();
|
|
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
|
+
const getConfig = (path) => {
|
|
60
|
+
var _a, _b, _c;
|
|
61
|
+
const c = JSON.parse(fs_1.default.readFileSync(path, "utf8"));
|
|
62
|
+
if (!validate(Object.assign({}, c))) {
|
|
66
63
|
return E.left(new errors_1.InvalidSchemaConfiguration(JSON.stringify(validate.errors[0].message)));
|
|
67
64
|
}
|
|
68
|
-
|
|
65
|
+
const config = c.spec;
|
|
69
66
|
if (config.backends) {
|
|
70
|
-
config.backends.map(
|
|
67
|
+
config.backends.map((b) => {
|
|
71
68
|
// Setting round-robin by default
|
|
72
69
|
b.balancingAlgorithm = b.balancingAlgorithm
|
|
73
|
-
? b.balancingAlgorithm
|
|
70
|
+
? b.balancingAlgorithm
|
|
71
|
+
: types_1.LB_ALGORITHM.ROUND_ROBIN;
|
|
74
72
|
return b;
|
|
75
73
|
});
|
|
76
|
-
|
|
77
|
-
return b.balancingAlgorithm === types_1.LB_ALGORITHM.ROUND_ROBIN && b.sessionAffinity;
|
|
78
|
-
});
|
|
79
|
-
var hasBadAlgorithm = config.backends.some(function (b) {
|
|
80
|
-
return b.balancingAlgorithm !== types_1.LB_ALGORITHM.ROUND_ROBIN
|
|
81
|
-
&& b.balancingAlgorithm !== types_1.LB_ALGORITHM.LEAST_SESSIONS;
|
|
82
|
-
});
|
|
83
|
-
if (hasBadCombiniation) {
|
|
74
|
+
if (hasBadCombiniation(config.backends)) {
|
|
84
75
|
return E.left(new errors_1.BadAlgorithmAndAffinityCombination());
|
|
85
76
|
}
|
|
86
|
-
if (hasBadAlgorithm) {
|
|
77
|
+
if (hasBadAlgorithm(config.backends)) {
|
|
87
78
|
return E.left(new errors_1.InvalidLoadBalancerAlgorithm());
|
|
88
79
|
}
|
|
89
80
|
}
|
|
81
|
+
if (!((_a = config === null || config === void 0 ? void 0 : config.cache) === null || _a === void 0 ? void 0 : _a.provider)) {
|
|
82
|
+
config.cache = {
|
|
83
|
+
provider: types_1.CACHE_PROVIDER.MEMORY
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (((_b = config === null || config === void 0 ? void 0 : config.cache) === null || _b === void 0 ? void 0 : _b.provider) === types_1.CACHE_PROVIDER.REDIS &&
|
|
87
|
+
!((_c = config === null || config === void 0 ? void 0 : config.cache) === null || _c === void 0 ? void 0 : _c.parameters)) {
|
|
88
|
+
config.cache = {
|
|
89
|
+
provider: types_1.CACHE_PROVIDER.REDIS,
|
|
90
|
+
parameters: "host=localhost,port=6379"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
90
93
|
return E.right(config);
|
|
91
94
|
};
|
|
92
95
|
exports.getConfig = getConfig;
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -22,6 +22,18 @@ export declare const schema: {
|
|
|
22
22
|
description: string;
|
|
23
23
|
type: string;
|
|
24
24
|
};
|
|
25
|
+
cache: {
|
|
26
|
+
type: string;
|
|
27
|
+
properties: {
|
|
28
|
+
provider: {
|
|
29
|
+
enum: string[];
|
|
30
|
+
};
|
|
31
|
+
parameters: {
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
required: string[];
|
|
36
|
+
};
|
|
25
37
|
backends: {
|
|
26
38
|
description: string;
|
|
27
39
|
type: string;
|
|
@@ -35,18 +47,9 @@ export declare const schema: {
|
|
|
35
47
|
balancingAlgorithm: {
|
|
36
48
|
enum: string[];
|
|
37
49
|
};
|
|
38
|
-
|
|
50
|
+
withSessionAffinity: {
|
|
39
51
|
description: string;
|
|
40
52
|
type: string;
|
|
41
|
-
properties: {
|
|
42
|
-
enabled: {
|
|
43
|
-
type: string;
|
|
44
|
-
};
|
|
45
|
-
ref: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
required: string[];
|
|
50
53
|
};
|
|
51
54
|
};
|
|
52
55
|
required: string[];
|
package/dist/config/schema.js
CHANGED
|
@@ -20,60 +20,63 @@ exports.schema = void 0;
|
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
22
|
exports.schema = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
$id: "https://json-schema.org/draft/2020-12/schema",
|
|
24
|
+
title: "Location Service configuration",
|
|
25
|
+
description: "Configuration for an instance of the Location Service",
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
kind: {
|
|
29
|
+
enum: ["Location", "location"]
|
|
30
30
|
},
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
apiVersion: {
|
|
32
|
+
enum: ["v2draft1"]
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
metadata: {
|
|
35
|
+
description: "Resource metadata",
|
|
36
|
+
type: "object"
|
|
37
37
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
spec: {
|
|
39
|
+
description: "Operations spec for Location",
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
bindAddr: {
|
|
43
|
+
description: "Ipv4 interface to accept request on",
|
|
44
|
+
type: "string"
|
|
45
45
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
"properties": {
|
|
53
|
-
"ref": {
|
|
54
|
-
"type": "string"
|
|
46
|
+
cache: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
provider: {
|
|
50
|
+
enum: ["memory", "redis"]
|
|
55
51
|
},
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
parameters: {
|
|
53
|
+
type: "string"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
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"
|
|
58
67
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"type": "object",
|
|
62
|
-
"properties": {
|
|
63
|
-
"enabled": {
|
|
64
|
-
"type": "boolean"
|
|
65
|
-
},
|
|
66
|
-
"ref": {
|
|
67
|
-
"type": "string"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"required": ["ref"]
|
|
68
|
+
balancingAlgorithm: {
|
|
69
|
+
enum: ["round-robin", "least-sessions"]
|
|
71
70
|
},
|
|
71
|
+
withSessionAffinity: {
|
|
72
|
+
description: "Optional session affinity",
|
|
73
|
+
type: "boolean"
|
|
74
|
+
}
|
|
72
75
|
},
|
|
73
|
-
|
|
74
|
-
}
|
|
76
|
+
required: ["ref"]
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
|
-
|
|
81
|
+
required: ["kind", "spec", "apiVersion"]
|
|
79
82
|
};
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,23 +1,59 @@
|
|
|
1
|
-
import grpc
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
2
2
|
export declare type LocationError = UnsupportedSchema | NotRoutesFoundForAOR;
|
|
3
3
|
export declare type InvalidConfiguration = BadAlgorithmAndAffinityCombination | InvalidSchemaConfiguration;
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when the location service returns an unsupported schema.
|
|
6
|
+
*/
|
|
4
7
|
export declare class UnsupportedSchema extends Error {
|
|
5
8
|
code: grpc.status;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new UnsupportedSchema error.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} aor - The AOR that was requested
|
|
13
|
+
*/
|
|
6
14
|
constructor(aor: string);
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when the location service returns no routes for the AOR.
|
|
18
|
+
*/
|
|
8
19
|
export declare class NotRoutesFoundForAOR extends Error {
|
|
9
20
|
code: number;
|
|
21
|
+
/**
|
|
22
|
+
* Create a new NotRoutesFoundForAOR error.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} aor - The AOR that was requested
|
|
25
|
+
*/
|
|
10
26
|
constructor(aor: string);
|
|
11
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when the location finds a bad configuration.
|
|
30
|
+
*/
|
|
12
31
|
export declare class InvalidSchemaConfiguration extends Error {
|
|
13
32
|
code: grpc.status;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new InvalidSchemaConfiguration error.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} msg - Message from the validation error
|
|
37
|
+
*/
|
|
14
38
|
constructor(msg: string);
|
|
15
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Error thrown when the location finds incompatible algorithm and session affinity.
|
|
42
|
+
*/
|
|
16
43
|
export declare class BadAlgorithmAndAffinityCombination extends Error {
|
|
17
44
|
code: grpc.status;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new BadAlgorithmAndAffinityCombination error.
|
|
47
|
+
*/
|
|
18
48
|
constructor();
|
|
19
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when the location finds an invalid balancing algorithm.
|
|
52
|
+
*/
|
|
20
53
|
export declare class InvalidLoadBalancerAlgorithm extends Error {
|
|
21
54
|
code: grpc.status;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new InvalidLoadBalancerAlgorithm error.
|
|
57
|
+
*/
|
|
22
58
|
constructor();
|
|
23
59
|
}
|
package/dist/errors.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
17
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
26
|
exports.InvalidLoadBalancerAlgorithm = exports.BadAlgorithmAndAffinityCombination = exports.InvalidSchemaConfiguration = exports.NotRoutesFoundForAOR = exports.UnsupportedSchema = void 0;
|
|
19
27
|
/*
|
|
@@ -34,58 +42,79 @@ exports.InvalidLoadBalancerAlgorithm = exports.BadAlgorithmAndAffinityCombinatio
|
|
|
34
42
|
* See the License for the specific language governing permissions and
|
|
35
43
|
* limitations under the License.
|
|
36
44
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when the location service returns an unsupported schema.
|
|
48
|
+
*/
|
|
49
|
+
class UnsupportedSchema extends Error {
|
|
50
|
+
/**
|
|
51
|
+
* Create a new UnsupportedSchema error.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} aor - The AOR that was requested
|
|
54
|
+
*/
|
|
55
|
+
constructor(aor) {
|
|
56
|
+
super(`aor ${aor} has an invalid schema, only "sip:" or "backend:" are allowed`);
|
|
57
|
+
this.code = grpc.status.INVALID_ARGUMENT;
|
|
43
58
|
// Set the prototype explicitly.
|
|
44
|
-
Object.setPrototypeOf(
|
|
45
|
-
return _this;
|
|
59
|
+
Object.setPrototypeOf(this, UnsupportedSchema.prototype);
|
|
46
60
|
}
|
|
47
|
-
|
|
48
|
-
}(Error));
|
|
61
|
+
}
|
|
49
62
|
exports.UnsupportedSchema = UnsupportedSchema;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown when the location service returns no routes for the AOR.
|
|
65
|
+
*/
|
|
66
|
+
class NotRoutesFoundForAOR extends Error {
|
|
67
|
+
/**
|
|
68
|
+
* Create a new NotRoutesFoundForAOR error.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} aor - The AOR that was requested
|
|
71
|
+
*/
|
|
72
|
+
constructor(aor) {
|
|
73
|
+
super(`no routes found for aor: ${aor}`);
|
|
74
|
+
this.code = grpc.status.NOT_FOUND;
|
|
75
|
+
Object.setPrototypeOf(this, NotRoutesFoundForAOR.prototype);
|
|
57
76
|
}
|
|
58
|
-
|
|
59
|
-
}(Error));
|
|
77
|
+
}
|
|
60
78
|
exports.NotRoutesFoundForAOR = NotRoutesFoundForAOR;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Error thrown when the location finds a bad configuration.
|
|
81
|
+
*/
|
|
82
|
+
class InvalidSchemaConfiguration extends Error {
|
|
83
|
+
/**
|
|
84
|
+
* Create a new InvalidSchemaConfiguration error.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} msg - Message from the validation error
|
|
87
|
+
*/
|
|
88
|
+
constructor(msg) {
|
|
89
|
+
super(msg);
|
|
90
|
+
this.code = grpc.status.INVALID_ARGUMENT;
|
|
91
|
+
Object.setPrototypeOf(this, InvalidSchemaConfiguration.prototype);
|
|
68
92
|
}
|
|
69
|
-
|
|
70
|
-
}(Error));
|
|
93
|
+
}
|
|
71
94
|
exports.InvalidSchemaConfiguration = InvalidSchemaConfiguration;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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);
|
|
78
105
|
}
|
|
79
|
-
|
|
80
|
-
}(Error));
|
|
106
|
+
}
|
|
81
107
|
exports.BadAlgorithmAndAffinityCombination = BadAlgorithmAndAffinityCombination;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
88
118
|
}
|
|
89
|
-
|
|
90
|
-
}(Error));
|
|
119
|
+
}
|
|
91
120
|
exports.InvalidLoadBalancerAlgorithm = InvalidLoadBalancerAlgorithm;
|
package/dist/helper.d.ts
ADDED