@webiny/api-elasticsearch 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.f6dc066313
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/README.md +10 -0
- package/client.d.ts +2 -2
- package/client.js +11 -30
- package/client.js.map +1 -1
- package/compression.js +7 -14
- package/compression.js.map +1 -1
- package/cursors.d.ts +1 -1
- package/cursors.js +2 -10
- package/cursors.js.map +1 -1
- package/db/entity.d.ts +7 -0
- package/db/entity.js +20 -0
- package/db/entity.js.map +1 -0
- package/db/index.d.ts +3 -0
- package/db/index.js +5 -0
- package/db/index.js.map +1 -0
- package/db/table.d.ts +7 -0
- package/db/table.js +17 -0
- package/db/table.js.map +1 -0
- package/db/types.d.ts +6 -0
- package/db/types.js +3 -0
- package/db/types.js.map +1 -0
- package/index.d.ts +18 -17
- package/index.js +27 -197
- package/index.js.map +1 -1
- package/indexConfiguration/base.d.ts +1 -1
- package/indexConfiguration/base.js +3 -10
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.d.ts +1 -1
- package/indexConfiguration/common.js +1 -8
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.d.ts +2 -3
- package/indexConfiguration/index.js +2 -38
- package/indexConfiguration/index.js.map +1 -1
- package/indexPrefix.js +2 -9
- package/indexPrefix.js.map +1 -1
- package/indices.d.ts +1 -2
- package/indices.js +6 -16
- package/indices.js.map +1 -1
- package/limit.js +1 -8
- package/limit.js.map +1 -1
- package/normalize.js +3 -11
- package/normalize.js.map +1 -1
- package/operations/ElasticsearchCatHealth.d.ts +2 -2
- package/operations/ElasticsearchCatHealth.js +6 -13
- package/operations/ElasticsearchCatHealth.js.map +1 -1
- package/operations/ElasticsearchCatNodes.d.ts +2 -2
- package/operations/ElasticsearchCatNodes.js +6 -13
- package/operations/ElasticsearchCatNodes.js.map +1 -1
- package/operations/index.d.ts +3 -3
- package/operations/index.js +3 -38
- package/operations/index.js.map +1 -1
- package/operations/stripConnectionFromException.js +1 -8
- package/operations/stripConnectionFromException.js.map +1 -1
- package/operations/types.js +1 -7
- package/operations/types.js.map +1 -1
- package/operators.d.ts +2 -5
- package/operators.js +3 -41
- package/operators.js.map +1 -1
- package/package.json +13 -12
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchFieldPlugin.js +2 -9
- package/plugins/definition/ElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchIndexPlugin.d.ts +2 -10
- package/plugins/definition/ElasticsearchIndexPlugin.js +4 -23
- package/plugins/definition/ElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.d.ts +1 -5
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js +2 -17
- package/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/definition/ElasticsearchSortModifierPlugin.js +4 -12
- package/plugins/definition/ElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/definition/index.d.ts +6 -6
- package/plugins/definition/index.js +6 -71
- package/plugins/definition/index.js.map +1 -1
- package/plugins/index.d.ts +2 -2
- package/plugins/index.js +2 -27
- package/plugins/index.js.map +1 -1
- package/plugins/operator/andIn.d.ts +2 -2
- package/plugins/operator/andIn.js +2 -9
- package/plugins/operator/andIn.js.map +1 -1
- package/plugins/operator/between.d.ts +2 -2
- package/plugins/operator/between.js +2 -9
- package/plugins/operator/between.js.map +1 -1
- package/plugins/operator/contains.d.ts +2 -2
- package/plugins/operator/contains.js +4 -11
- package/plugins/operator/contains.js.map +1 -1
- package/plugins/operator/equal.d.ts +2 -2
- package/plugins/operator/equal.js +2 -9
- package/plugins/operator/equal.js.map +1 -1
- package/plugins/operator/gt.d.ts +2 -2
- package/plugins/operator/gt.js +2 -9
- package/plugins/operator/gt.js.map +1 -1
- package/plugins/operator/gte.d.ts +2 -2
- package/plugins/operator/gte.js +2 -9
- package/plugins/operator/gte.js.map +1 -1
- package/plugins/operator/in.d.ts +2 -2
- package/plugins/operator/in.js +2 -9
- package/plugins/operator/in.js.map +1 -1
- package/plugins/operator/index.d.ts +15 -16
- package/plugins/operator/index.js +15 -181
- package/plugins/operator/index.js.map +1 -1
- package/plugins/operator/lt.d.ts +2 -2
- package/plugins/operator/lt.js +2 -9
- package/plugins/operator/lt.js.map +1 -1
- package/plugins/operator/lte.d.ts +2 -2
- package/plugins/operator/lte.js +2 -9
- package/plugins/operator/lte.js.map +1 -1
- package/plugins/operator/not.d.ts +2 -2
- package/plugins/operator/not.js +2 -9
- package/plugins/operator/not.js.map +1 -1
- package/plugins/operator/notBetween.d.ts +2 -2
- package/plugins/operator/notBetween.js +2 -9
- package/plugins/operator/notBetween.js.map +1 -1
- package/plugins/operator/notContains.d.ts +2 -2
- package/plugins/operator/notContains.js +4 -11
- package/plugins/operator/notContains.js.map +1 -1
- package/plugins/operator/notIn.d.ts +2 -2
- package/plugins/operator/notIn.js +2 -9
- package/plugins/operator/notIn.js.map +1 -1
- package/plugins/operator/notStartsWith.d.ts +2 -2
- package/plugins/operator/notStartsWith.js +2 -9
- package/plugins/operator/notStartsWith.js.map +1 -1
- package/plugins/operator/startsWith.d.ts +2 -2
- package/plugins/operator/startsWith.js +2 -9
- package/plugins/operator/startsWith.js.map +1 -1
- package/sharedIndex.js +2 -9
- package/sharedIndex.js.map +1 -1
- package/sort.d.ts +2 -2
- package/sort.js +8 -16
- package/sort.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +28 -26
- package/types.js.map +1 -1
- package/utils/createIndex.d.ts +0 -1
- package/utils/createIndex.js +7 -19
- package/utils/createIndex.js.map +1 -1
- package/utils/index.d.ts +3 -3
- package/utils/index.js +3 -27
- package/utils/index.js.map +1 -1
- package/utils/waitUntilHealthy/UnhealthyClusterError.js +2 -9
- package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
- package/utils/waitUntilHealthy/WaitUntilHealthy.d.ts +3 -3
- package/utils/waitUntilHealthy/WaitUntilHealthy.js +22 -29
- package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +2 -9
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
- package/utils/waitUntilHealthy/index.d.ts +6 -6
- package/utils/waitUntilHealthy/index.js +6 -49
- package/utils/waitUntilHealthy/index.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.d.ts +2 -2
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +2 -10
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/IReason.js +1 -5
- package/utils/waitUntilHealthy/reason/MemoryReason.d.ts +1 -1
- package/utils/waitUntilHealthy/reason/MemoryReason.js +2 -10
- package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.d.ts +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.js +2 -10
- package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/index.d.ts +3 -3
- package/utils/waitUntilHealthy/reason/index.js +3 -38
- package/utils/waitUntilHealthy/reason/index.js.map +1 -1
- package/where.d.ts +3 -3
- package/where.js +7 -16
- package/where.js.map +1 -1
- package/indexConfiguration/japanese.d.ts +0 -6
- package/indexConfiguration/japanese.js +0 -121
- package/indexConfiguration/japanese.js.map +0 -1
- package/plugins/operator/japanese/contains.d.ts +0 -8
- package/plugins/operator/japanese/contains.js +0 -44
- package/plugins/operator/japanese/contains.js.map +0 -1
package/utils/createIndex.d.ts
CHANGED
package/utils/createIndex.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createIndex = void 0;
|
|
8
|
-
var _indices = require("../indices");
|
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
1
|
+
import { getLastAddedIndexPlugin } from "../indices.js";
|
|
2
|
+
import WebinyError from "@webiny/error";
|
|
10
3
|
const indexExists = async params => {
|
|
11
4
|
const {
|
|
12
5
|
client,
|
|
@@ -29,7 +22,7 @@ const indexExists = async params => {
|
|
|
29
22
|
onExists();
|
|
30
23
|
}
|
|
31
24
|
return true;
|
|
32
|
-
} catch
|
|
25
|
+
} catch {
|
|
33
26
|
console.error(`Could not determine if the index "${index}" exists.`);
|
|
34
27
|
}
|
|
35
28
|
return false;
|
|
@@ -40,7 +33,6 @@ const indexCreate = async params => {
|
|
|
40
33
|
index,
|
|
41
34
|
plugin,
|
|
42
35
|
tenant,
|
|
43
|
-
locale,
|
|
44
36
|
type,
|
|
45
37
|
onError
|
|
46
38
|
} = params;
|
|
@@ -56,7 +48,7 @@ const indexCreate = async params => {
|
|
|
56
48
|
if (onError) {
|
|
57
49
|
error = onError(ex);
|
|
58
50
|
}
|
|
59
|
-
throw new
|
|
51
|
+
throw new WebinyError(error.message || `Could not create Elasticsearch index for the ${type}.`, error.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
|
|
60
52
|
error: {
|
|
61
53
|
...error,
|
|
62
54
|
message: error.message,
|
|
@@ -64,24 +56,21 @@ const indexCreate = async params => {
|
|
|
64
56
|
data: error.data
|
|
65
57
|
},
|
|
66
58
|
type,
|
|
67
|
-
locale,
|
|
68
59
|
tenant,
|
|
69
60
|
index,
|
|
70
61
|
body: plugin.body
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
64
|
};
|
|
74
|
-
const createIndex = async params => {
|
|
65
|
+
export const createIndex = async params => {
|
|
75
66
|
const {
|
|
76
67
|
plugins,
|
|
77
68
|
type,
|
|
78
|
-
locale,
|
|
79
69
|
onExists
|
|
80
70
|
} = params;
|
|
81
|
-
const plugin =
|
|
71
|
+
const plugin = getLastAddedIndexPlugin({
|
|
82
72
|
container: plugins,
|
|
83
|
-
type
|
|
84
|
-
locale
|
|
73
|
+
type
|
|
85
74
|
});
|
|
86
75
|
const exists = await indexExists(params);
|
|
87
76
|
if (exists) {
|
|
@@ -95,6 +84,5 @@ const createIndex = async params => {
|
|
|
95
84
|
plugin
|
|
96
85
|
});
|
|
97
86
|
};
|
|
98
|
-
exports.createIndex = createIndex;
|
|
99
87
|
|
|
100
88
|
//# sourceMappingURL=createIndex.js.map
|
package/utils/createIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getLastAddedIndexPlugin","WebinyError","indexExists","params","client","index","onExists","response","indices","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","body","console","error","indexCreate","plugin","tenant","type","onError","create","ex","message","code","data","createIndex","plugins","container"],"sources":["createIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getLastAddedIndexPlugin } from \"~/indices.js\";\nimport type { ElasticsearchIndexPlugin } from \"~/plugins/index.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface OnExists {\n (): void;\n}\n\ninterface OnError {\n (ex: Error): Error;\n}\n\ninterface ExistsIndexParams {\n client: Client;\n index: string;\n onExists?: OnExists;\n}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index, onExists } = params;\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (!response.body) {\n return false;\n }\n if (onExists) {\n onExists();\n }\n return true;\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n return false;\n};\n\ninterface IndexCreateParams {\n client: Client;\n index: string;\n type: string;\n tenant: string;\n plugin: ElasticsearchIndexPlugin;\n onError?: OnError;\n}\n\nconst indexCreate = async (params: IndexCreateParams): Promise<void> => {\n const { client, index, plugin, tenant, type, onError } = params;\n\n try {\n await client.indices.create({\n index,\n body: {\n ...plugin.body\n }\n });\n } catch (ex) {\n let error = ex;\n if (onError) {\n error = onError(ex);\n }\n throw new WebinyError(\n error.message || `Could not create Elasticsearch index for the ${type}.`,\n error.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...error,\n message: error.message,\n code: error.code,\n data: error.data\n },\n type,\n tenant,\n index,\n body: plugin.body\n }\n );\n }\n};\n\ninterface CreateIndexParams {\n client: Client;\n plugins: PluginsContainer;\n type: string;\n tenant: string;\n index: string;\n onExists?: OnExists;\n onError?: OnError;\n}\n\nexport const createIndex = async (params: CreateIndexParams): Promise<void> => {\n const { plugins, type, onExists } = params;\n const plugin = getLastAddedIndexPlugin<ElasticsearchIndexPlugin>({\n container: plugins,\n type\n });\n\n const exists = await indexExists(params);\n if (exists) {\n if (onExists) {\n onExists();\n }\n return;\n }\n\n await indexCreate({\n ...params,\n plugin\n });\n};\n"],"mappings":"AAEA,SAASA,uBAAuB;AAEhC,OAAOC,WAAW,MAAM,eAAe;AAgBvC,MAAMC,WAAW,GAAG,MAAOC,MAAyB,IAAuB;EACvE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGH,MAAM;EAE1C,IAAI;IACA,MAAMI,QAAQ,GAAG,MAAMH,MAAM,CAACI,OAAO,CAACC,MAAM,CAAC;MACzCJ,KAAK;MACLK,kBAAkB,EAAE,KAAK;MACzBC,gBAAgB,EAAE,IAAI;MACtBC,gBAAgB,EAAE,IAAI;MACtBC,aAAa,EAAE,KAAK;MACpBC,KAAK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,MAAM;EAC1C,MAAMgB,MAAM,GAAGnB,uBAAuB,CAA2B;IAC7D8B,SAAS,EAAED,OAAO;IAClBR;EACJ,CAAC,CAAC;EAEF,MAAMZ,MAAM,GAAG,MAAMP,WAAW,CAACC,MAAM,CAAC;EACxC,IAAIM,MAAM,EAAE;IACR,IAAIH,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC;IACd;IACA;EACJ;EAEA,MAAMY,WAAW,CAAC;IACd,GAAGf,MAAM;IACTgB;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./waitUntilHealthy";
|
|
2
|
-
export * from "./createIndex";
|
|
3
|
-
export * from "./waitUntilHealthy";
|
|
1
|
+
export * from "./waitUntilHealthy/index.js";
|
|
2
|
+
export * from "./createIndex.js";
|
|
3
|
+
export * from "./waitUntilHealthy/index.js";
|
package/utils/index.js
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _waitUntilHealthy = require("./waitUntilHealthy");
|
|
7
|
-
Object.keys(_waitUntilHealthy).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _waitUntilHealthy[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _waitUntilHealthy[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _createIndex = require("./createIndex");
|
|
18
|
-
Object.keys(_createIndex).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _createIndex[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _createIndex[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
1
|
+
export * from "./waitUntilHealthy/index.js";
|
|
2
|
+
export * from "./createIndex.js";
|
|
3
|
+
export * from "./waitUntilHealthy/index.js";
|
|
28
4
|
|
|
29
5
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./waitUntilHealthy/index.js\";\nexport * from \"./createIndex.js\";\nexport * from \"./waitUntilHealthy/index.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UnhealthyClusterError = void 0;
|
|
7
|
-
var _error = require("@webiny/error");
|
|
8
|
-
class UnhealthyClusterError extends _error.WebinyError {
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
export class UnhealthyClusterError extends WebinyError {
|
|
9
3
|
constructor(maxWaitingTime) {
|
|
10
4
|
super({
|
|
11
5
|
message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,
|
|
@@ -13,6 +7,5 @@ class UnhealthyClusterError extends _error.WebinyError {
|
|
|
13
7
|
});
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
exports.UnhealthyClusterError = UnhealthyClusterError;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=UnhealthyClusterError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","UnhealthyClusterError","constructor","maxWaitingTime","message","code"],"sources":["UnhealthyClusterError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class UnhealthyClusterError extends WebinyError {\n public constructor(maxWaitingTime: number) {\n super({\n message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,\n code: \"UNHEALTHY_CLUSTER\"\n });\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAAC;EAC5CE,WAAWA,CAACC,cAAsB,EAAE;IACvC,KAAK,CAAC;MACFC,OAAO,EAAE,qCAAqCD,cAAc,WAAW;MACvEE,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Client } from "../../client";
|
|
2
|
-
import { ElasticsearchCatClusterHealthStatus } from "../../operations/types";
|
|
3
|
-
import type { ClusterHealthReason, MemoryReason, ProcessorReason } from "./reason";
|
|
1
|
+
import type { Client } from "../../client.js";
|
|
2
|
+
import { ElasticsearchCatClusterHealthStatus } from "../../operations/types.js";
|
|
3
|
+
import type { ClusterHealthReason, MemoryReason, ProcessorReason } from "./reason/index.js";
|
|
4
4
|
export type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;
|
|
5
5
|
export interface IWaitUntilHealthyParams {
|
|
6
6
|
/**
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
var _ElasticsearchCatHealth = require("../../operations/ElasticsearchCatHealth");
|
|
8
|
-
var _ElasticsearchCatNodes = require("../../operations/ElasticsearchCatNodes");
|
|
9
|
-
var _types = require("../../operations/types");
|
|
10
|
-
var _UnhealthyClusterError = require("./UnhealthyClusterError");
|
|
11
|
-
var _reason = require("./reason");
|
|
12
|
-
var _WaitingHealthyClusterAbortedError = require("./WaitingHealthyClusterAbortedError");
|
|
1
|
+
import { ElasticsearchCatHealth } from "../../operations/ElasticsearchCatHealth.js";
|
|
2
|
+
import { ElasticsearchCatNodes } from "../../operations/ElasticsearchCatNodes.js";
|
|
3
|
+
import { ElasticsearchCatClusterHealthStatus } from "../../operations/types.js";
|
|
4
|
+
import { UnhealthyClusterError } from "./UnhealthyClusterError.js";
|
|
5
|
+
import { createClusterHealthStatusReason, createMemoryReason, createProcessorReason } from "./reason/index.js";
|
|
6
|
+
import { WaitingHealthyClusterAbortedError } from "./WaitingHealthyClusterAbortedError.js";
|
|
13
7
|
const WAITING_TIME_STEP = 10;
|
|
14
8
|
class WaitUntilHealthy {
|
|
15
9
|
aborted = false;
|
|
16
10
|
constructor(client, options) {
|
|
17
11
|
this.client = client;
|
|
18
12
|
this.options = options;
|
|
19
|
-
this.catHealth = new
|
|
20
|
-
this.catNodes = new
|
|
13
|
+
this.catHealth = new ElasticsearchCatHealth(this.client);
|
|
14
|
+
this.catNodes = new ElasticsearchCatNodes(this.client);
|
|
21
15
|
}
|
|
22
16
|
abort() {
|
|
23
17
|
this.aborted = true;
|
|
@@ -28,7 +22,7 @@ class WaitUntilHealthy {
|
|
|
28
22
|
*/
|
|
29
23
|
async wait(options) {
|
|
30
24
|
if (this.aborted) {
|
|
31
|
-
throw new
|
|
25
|
+
throw new WaitingHealthyClusterAbortedError(`Waiting for the cluster to become healthy was aborted even before it started.`);
|
|
32
26
|
}
|
|
33
27
|
const startedAt = new Date();
|
|
34
28
|
const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);
|
|
@@ -46,7 +40,7 @@ class WaitUntilHealthy {
|
|
|
46
40
|
runs
|
|
47
41
|
});
|
|
48
42
|
}
|
|
49
|
-
throw new
|
|
43
|
+
throw new UnhealthyClusterError(this.options.maxWaitingTime);
|
|
50
44
|
} else if (options?.onUnhealthy) {
|
|
51
45
|
await options.onUnhealthy({
|
|
52
46
|
startedAt,
|
|
@@ -60,7 +54,7 @@ class WaitUntilHealthy {
|
|
|
60
54
|
* Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.
|
|
61
55
|
*/
|
|
62
56
|
if (this.aborted) {
|
|
63
|
-
throw new
|
|
57
|
+
throw new WaitingHealthyClusterAbortedError();
|
|
64
58
|
}
|
|
65
59
|
runs++;
|
|
66
60
|
await new Promise(resolve => {
|
|
@@ -79,32 +73,32 @@ class WaitUntilHealthy {
|
|
|
79
73
|
try {
|
|
80
74
|
health = await this.catHealth.getHealth();
|
|
81
75
|
} catch (ex) {
|
|
82
|
-
return
|
|
76
|
+
return createClusterHealthStatusReason({
|
|
83
77
|
description: ex.message,
|
|
84
78
|
minimum: this.options.minClusterHealthStatus,
|
|
85
|
-
current:
|
|
79
|
+
current: ElasticsearchCatClusterHealthStatus.Red
|
|
86
80
|
});
|
|
87
81
|
}
|
|
88
82
|
try {
|
|
89
83
|
nodes = await this.catNodes.getNodes();
|
|
90
84
|
} catch (ex) {
|
|
91
|
-
return
|
|
85
|
+
return createClusterHealthStatusReason({
|
|
92
86
|
description: ex.message,
|
|
93
87
|
minimum: this.options.minClusterHealthStatus,
|
|
94
|
-
current:
|
|
88
|
+
current: ElasticsearchCatClusterHealthStatus.Red
|
|
95
89
|
});
|
|
96
90
|
}
|
|
97
91
|
const clusterHealthStatus = this.transformClusterHealthStatus(health.status);
|
|
98
92
|
const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
|
|
99
93
|
if (clusterHealthStatus > minClusterHealthStatus) {
|
|
100
|
-
return
|
|
94
|
+
return createClusterHealthStatusReason({
|
|
101
95
|
minimum: this.options.minClusterHealthStatus,
|
|
102
96
|
current: health.status
|
|
103
97
|
});
|
|
104
98
|
}
|
|
105
99
|
const processorPercent = this.getProcessorPercent(nodes);
|
|
106
100
|
if (processorPercent > this.options.maxProcessorPercent) {
|
|
107
|
-
return
|
|
101
|
+
return createProcessorReason({
|
|
108
102
|
maximum: this.options.maxProcessorPercent,
|
|
109
103
|
current: processorPercent
|
|
110
104
|
});
|
|
@@ -117,7 +111,7 @@ class WaitUntilHealthy {
|
|
|
117
111
|
}
|
|
118
112
|
const ramPercent = this.getRamPercent(nodes);
|
|
119
113
|
if (ramPercent > this.options.maxRamPercent) {
|
|
120
|
-
return
|
|
114
|
+
return createMemoryReason({
|
|
121
115
|
maximum: this.options.maxRamPercent,
|
|
122
116
|
current: ramPercent
|
|
123
117
|
});
|
|
@@ -138,20 +132,19 @@ class WaitUntilHealthy {
|
|
|
138
132
|
}
|
|
139
133
|
transformClusterHealthStatus(status) {
|
|
140
134
|
switch (status) {
|
|
141
|
-
case
|
|
135
|
+
case ElasticsearchCatClusterHealthStatus.Green:
|
|
142
136
|
return 1;
|
|
143
|
-
case
|
|
137
|
+
case ElasticsearchCatClusterHealthStatus.Yellow:
|
|
144
138
|
return 2;
|
|
145
|
-
case
|
|
139
|
+
case ElasticsearchCatClusterHealthStatus.Red:
|
|
146
140
|
return 3;
|
|
147
141
|
default:
|
|
148
142
|
return 99;
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
|
-
const createWaitUntilHealthy = (client, params) => {
|
|
146
|
+
export const createWaitUntilHealthy = (client, params) => {
|
|
153
147
|
return new WaitUntilHealthy(client, params);
|
|
154
148
|
};
|
|
155
|
-
exports.createWaitUntilHealthy = createWaitUntilHealthy;
|
|
156
149
|
|
|
157
150
|
//# sourceMappingURL=WaitUntilHealthy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ElasticsearchCatHealth","require","_ElasticsearchCatNodes","_types","_UnhealthyClusterError","_reason","_WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","ElasticsearchCatHealth","catNodes","ElasticsearchCatNodes","abort","wait","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","UnhealthyClusterError","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","createClusterHealthStatusReason","description","message","minimum","minClusterHealthStatus","current","ElasticsearchCatClusterHealthStatus","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","createProcessorReason","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","createMemoryReason","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params","exports"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import type { Client } from \"~/client\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes\";\nimport type {\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types\";\nimport { ElasticsearchCatClusterHealthStatus } from \"~/operations/types\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError\";\nimport type { ClusterHealthReason, MemoryReason, ProcessorReason } from \"./reason\";\nimport {\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason\n} from \"./reason\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,kCAAA,GAAAL,OAAA;AAEA,MAAMM,iBAAiB,GAAG,EAAE;AA0D5B,MAAMC,gBAAgB,CAAC;EAOXC,OAAO,GAAG,KAAK;EAEhBC,WAAWA,CAACC,MAAc,EAAEC,OAAgC,EAAE;IACjE,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,SAAS,GAAG,IAAIC,8CAAsB,CAAC,IAAI,CAACH,MAAM,CAAC;IACxD,IAAI,CAACI,QAAQ,GAAG,IAAIC,4CAAqB,CAAC,IAAI,CAACL,MAAM,CAAC;EAC1D;EAEOM,KAAKA,CAAA,EAAS;IACjB,IAAI,CAACR,OAAO,GAAG,IAAI;EACvB;EACA;AACJ;AACA;AACA;EACI,MAAaS,IAAIA,CAACN,OAAsB,EAA0C;IAC9E,IAAI,IAAI,CAACH,OAAO,EAAE;MACd,MAAM,IAAIU,oEAAiC,CACvC,+EACJ,CAAC;IACL;IACA,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAAC,CAAC;IAC5B,MAAMC,SAAS,GAAG,IAAID,IAAI,CAACD,SAAS,CAACG,OAAO,CAAC,CAAC,GAAG,IAAI,CA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AAM,EAAE4D,MAAM,CAAC;AAC/C,CAAC;AAACC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ElasticsearchCatHealth","ElasticsearchCatNodes","ElasticsearchCatClusterHealthStatus","UnhealthyClusterError","createClusterHealthStatusReason","createMemoryReason","createProcessorReason","WaitingHealthyClusterAbortedError","WAITING_TIME_STEP","WaitUntilHealthy","aborted","constructor","client","options","catHealth","catNodes","abort","wait","startedAt","Date","mustEndAt","getTime","maxWaitingTime","waitingTimeStep","runs","waitingReason","shouldWait","onTimeout","onUnhealthy","Promise","resolve","setTimeout","runningTime","health","nodes","getHealth","ex","description","message","minimum","minClusterHealthStatus","current","Red","getNodes","clusterHealthStatus","transformClusterHealthStatus","status","processorPercent","getProcessorPercent","maxProcessorPercent","maximum","maxRamPercent","undefined","ramPercent","getRamPercent","total","reduce","node","parseFloat","cpu","length","Green","Yellow","createWaitUntilHealthy","params"],"sources":["WaitUntilHealthy.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport { ElasticsearchCatHealth } from \"~/operations/ElasticsearchCatHealth.js\";\nimport { ElasticsearchCatNodes } from \"~/operations/ElasticsearchCatNodes.js\";\nimport type {\n IElasticsearchCatHealthResponse,\n IElasticsearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { ElasticsearchCatClusterHealthStatus } from \"~/operations/types.js\";\nimport { UnhealthyClusterError } from \"~/utils/waitUntilHealthy/UnhealthyClusterError.js\";\nimport type { ClusterHealthReason, MemoryReason, ProcessorReason } from \"./reason/index.js\";\nimport {\n createClusterHealthStatusReason,\n createMemoryReason,\n createProcessorReason\n} from \"./reason/index.js\";\nimport { WaitingHealthyClusterAbortedError } from \"./WaitingHealthyClusterAbortedError.js\";\n\nconst WAITING_TIME_STEP = 10;\n\nexport type WaitingReason = ProcessorReason | MemoryReason | ClusterHealthReason;\n\nexport interface IWaitUntilHealthyParams {\n /**\n * Minimum status allowed, otherwise the cluster is considered unhealthy.\n */\n minClusterHealthStatus:\n | ElasticsearchCatClusterHealthStatus.Green\n | ElasticsearchCatClusterHealthStatus.Yellow;\n /**\n * Maximum processor percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxProcessorPercent: number;\n /**\n * Maximum RAM percent allowed, otherwise the cluster is considered unhealthy.\n */\n maxRamPercent?: number;\n /**\n * Maximum time to wait in seconds.\n * This is to prevent infinite waiting in case the cluster never becomes healthy.\n */\n maxWaitingTime: number;\n /**\n * Time in seconds to wait between each check.\n * This is to prevent spamming the cluster with requests.\n * Default is WAITING_TIME_STEP seconds.\n */\n waitingTimeStep?: number;\n}\n\nexport interface IWaitOptionsOnUnhealthyParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptionsOnTimeoutParams {\n startedAt: Date;\n mustEndAt: Date;\n waitingTimeStep: number;\n runs: number;\n waitingReason: WaitingReason;\n}\n\nexport interface IWaitOptions {\n onUnhealthy?(params: IWaitOptionsOnUnhealthyParams): Promise<void>;\n onTimeout?(params: IWaitOptionsOnTimeoutParams): Promise<void>;\n}\n\nexport interface IWaitUntilHealthyWaitResponse {\n runningTime: number;\n runs: number;\n}\n\nclass WaitUntilHealthy {\n private readonly client: Client;\n private readonly options: IWaitUntilHealthyParams;\n\n private readonly catHealth: ElasticsearchCatHealth;\n private readonly catNodes: ElasticsearchCatNodes;\n\n private aborted = false;\n\n public constructor(client: Client, options: IWaitUntilHealthyParams) {\n this.client = client;\n this.options = options;\n\n this.catHealth = new ElasticsearchCatHealth(this.client);\n this.catNodes = new ElasticsearchCatNodes(this.client);\n }\n\n public abort(): void {\n this.aborted = true;\n }\n /**\n * @throws UnhealthyClusterError\n * @throws WaitingHealthyClusterAbortedError\n */\n public async wait(options?: IWaitOptions): Promise<IWaitUntilHealthyWaitResponse> {\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError(\n `Waiting for the cluster to become healthy was aborted even before it started.`\n );\n }\n const startedAt = new Date();\n const mustEndAt = new Date(startedAt.getTime() + this.options.maxWaitingTime * 1000);\n const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;\n let runs = 1;\n let waitingReason: WaitingReason | false;\n while ((waitingReason = await this.shouldWait())) {\n if (new Date() >= mustEndAt) {\n if (options?.onTimeout) {\n await options.onTimeout({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n throw new UnhealthyClusterError(this.options.maxWaitingTime);\n } else if (options?.onUnhealthy) {\n await options.onUnhealthy({\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason,\n runs\n });\n }\n /**\n * Abort check is separated from other IFs because it can be aborted in onUnhealthy callback.\n */\n if (this.aborted) {\n throw new WaitingHealthyClusterAbortedError();\n }\n runs++;\n await new Promise(resolve => {\n setTimeout(resolve, waitingTimeStep * 1000);\n });\n }\n\n const runningTime = new Date().getTime() - startedAt.getTime();\n\n return {\n runningTime,\n runs\n };\n }\n\n private async shouldWait(): Promise<WaitingReason | false> {\n let health: IElasticsearchCatHealthResponse;\n let nodes: IElasticsearchCatNodesResponse;\n try {\n health = await this.catHealth.getHealth();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n try {\n nodes = await this.catNodes.getNodes();\n } catch (ex) {\n return createClusterHealthStatusReason({\n description: ex.message,\n minimum: this.options.minClusterHealthStatus,\n current: ElasticsearchCatClusterHealthStatus.Red\n });\n }\n\n const clusterHealthStatus = this.transformClusterHealthStatus(health.status);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: health.status\n });\n }\n\n const processorPercent = this.getProcessorPercent(nodes);\n if (processorPercent > this.options.maxProcessorPercent) {\n return createProcessorReason({\n maximum: this.options.maxProcessorPercent,\n current: processorPercent\n });\n }\n /**\n * Possibly no max ram definition?\n */\n if (this.options.maxRamPercent === undefined) {\n return false;\n }\n\n const ramPercent = this.getRamPercent(nodes);\n if (ramPercent > this.options.maxRamPercent) {\n return createMemoryReason({\n maximum: this.options.maxRamPercent,\n current: ramPercent\n });\n }\n return false;\n }\n\n private getProcessorPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu);\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IElasticsearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"]);\n }, 0);\n return total / nodes.length;\n }\n\n private transformClusterHealthStatus(status: ElasticsearchCatClusterHealthStatus): number {\n switch (status) {\n case ElasticsearchCatClusterHealthStatus.Green:\n return 1;\n case ElasticsearchCatClusterHealthStatus.Yellow:\n return 2;\n case ElasticsearchCatClusterHealthStatus.Red:\n return 3;\n default:\n return 99;\n }\n }\n}\n\nexport type { WaitUntilHealthy };\n\nexport const createWaitUntilHealthy = (\n client: Client,\n params: IWaitUntilHealthyParams\n): WaitUntilHealthy => {\n return new WaitUntilHealthy(client, params);\n};\n"],"mappings":"AACA,SAASA,sBAAsB;AAC/B,SAASC,qBAAqB;AAK9B,SAASC,mCAAmC;AAC5C,SAASC,qBAAqB;AAE9B,SACIC,+BAA+B,EAC/BC,kBAAkB,EAClBC,qBAAqB;AAEzB,SAASC,iCAAiC;AAE1C,MAAMC,iBAAiB,GAAG,EAAE;AA0D5B,MAAMC,gBAAgB,CAAC;EAOXC,OAAO,GAAG,KAAK;EAEhBC,WAAWA,CAACC,MAAc,EAAEC,OAAgC,EAAE;IACjE,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,SAAS,GAAG,IAAId,sBAAsB,CAAC,IAAI,CAACY,MAAM,CAAC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AAOF,KAAK,GAAGrB,KAAK,CAAC0B,MAAM;EAC/B;EAEQf,4BAA4BA,CAACC,MAA2C,EAAU;IACtF,QAAQA,MAAM;MACV,KAAK5C,mCAAmC,CAAC2D,KAAK;QAC1C,OAAO,CAAC;MACZ,KAAK3D,mCAAmC,CAAC4D,MAAM;QAC3C,OAAO,CAAC;MACZ,KAAK5D,mCAAmC,CAACwC,GAAG;QACxC,OAAO,CAAC;MACZ;QACI,OAAO,EAAE;IACjB;EACJ;AACJ;AAIA,OAAO,MAAMqB,sBAAsB,GAAGA,CAClCnD,MAAc,EACdoD,MAA+B,KACZ;EACnB,OAAO,IAAIvD,gBAAgB,CAACG,MAAM,EAAEoD,MAAM,CAAC;AAC/C,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WaitingHealthyClusterAbortedError = void 0;
|
|
7
|
-
var _error = require("@webiny/error");
|
|
8
|
-
class WaitingHealthyClusterAbortedError extends _error.WebinyError {
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
export class WaitingHealthyClusterAbortedError extends WebinyError {
|
|
9
3
|
constructor(message) {
|
|
10
4
|
super({
|
|
11
5
|
message: message || `Waiting for the cluster to become healthy was aborted.`,
|
|
@@ -13,6 +7,5 @@ class WaitingHealthyClusterAbortedError extends _error.WebinyError {
|
|
|
13
7
|
});
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
exports.WaitingHealthyClusterAbortedError = WaitingHealthyClusterAbortedError;
|
|
17
10
|
|
|
18
11
|
//# sourceMappingURL=WaitingHealthyClusterAbortedError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","WaitingHealthyClusterAbortedError","constructor","message","code"],"sources":["WaitingHealthyClusterAbortedError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class WaitingHealthyClusterAbortedError extends WebinyError {\n public constructor(message?: string) {\n super({\n message: message || `Waiting for the cluster to become healthy was aborted.`,\n code: \"WAITING_HEALTHY_CLUSTER_ABORTED\"\n });\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,iCAAiC,SAASD,WAAW,CAAC;EACxDE,WAAWA,CAACC,OAAgB,EAAE;IACjC,KAAK,CAAC;MACFA,OAAO,EAAEA,OAAO,IAAI,wDAAwD;MAC5EC,IAAI,EAAE;IACV,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./WaitingHealthyClusterAbortedError";
|
|
2
|
-
export * from "./UnhealthyClusterError";
|
|
3
|
-
export * from "./WaitUntilHealthy";
|
|
4
|
-
export * from "./UnhealthyClusterError";
|
|
5
|
-
export * from "./WaitUntilHealthy";
|
|
6
|
-
export * from "./reason";
|
|
1
|
+
export * from "./WaitingHealthyClusterAbortedError.js";
|
|
2
|
+
export * from "./UnhealthyClusterError.js";
|
|
3
|
+
export * from "./WaitUntilHealthy.js";
|
|
4
|
+
export * from "./UnhealthyClusterError.js";
|
|
5
|
+
export * from "./WaitUntilHealthy.js";
|
|
6
|
+
export * from "./reason/index.js";
|
|
@@ -1,51 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(_WaitingHealthyClusterAbortedError).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _WaitingHealthyClusterAbortedError[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _WaitingHealthyClusterAbortedError[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _UnhealthyClusterError = require("./UnhealthyClusterError");
|
|
18
|
-
Object.keys(_UnhealthyClusterError).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _UnhealthyClusterError[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _UnhealthyClusterError[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _WaitUntilHealthy = require("./WaitUntilHealthy");
|
|
29
|
-
Object.keys(_WaitUntilHealthy).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _WaitUntilHealthy[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _WaitUntilHealthy[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _reason = require("./reason");
|
|
40
|
-
Object.keys(_reason).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _reason[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _reason[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
export * from "./WaitingHealthyClusterAbortedError.js";
|
|
2
|
+
export * from "./UnhealthyClusterError.js";
|
|
3
|
+
export * from "./WaitUntilHealthy.js";
|
|
4
|
+
export * from "./UnhealthyClusterError.js";
|
|
5
|
+
export * from "./WaitUntilHealthy.js";
|
|
6
|
+
export * from "./reason/index.js";
|
|
50
7
|
|
|
51
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./WaitingHealthyClusterAbortedError.js\";\nexport * from \"./UnhealthyClusterError.js\";\nexport * from \"./WaitUntilHealthy.js\";\nexport * from \"./UnhealthyClusterError.js\";\nexport * from \"./WaitUntilHealthy.js\";\nexport * from \"./reason/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ElasticsearchCatClusterHealthStatus } from "../../../operations";
|
|
2
|
-
import type { IReason } from "
|
|
1
|
+
import type { ElasticsearchCatClusterHealthStatus } from "../../../operations/index.js";
|
|
2
|
+
import type { IReason } from "../../../utils/waitUntilHealthy/reason/IReason.js";
|
|
3
3
|
export interface IClusterHealthReasonParams {
|
|
4
4
|
minimum: ElasticsearchCatClusterHealthStatus;
|
|
5
5
|
current: ElasticsearchCatClusterHealthStatus;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createClusterHealthStatusReason = exports.ClusterHealthReason = void 0;
|
|
7
|
-
class ClusterHealthReason {
|
|
1
|
+
export class ClusterHealthReason {
|
|
8
2
|
name = "clusterHealth";
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.minimum = params.minimum;
|
|
@@ -12,10 +6,8 @@ class ClusterHealthReason {
|
|
|
12
6
|
this.description = params.description;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createClusterHealthStatusReason = params => {
|
|
9
|
+
export const createClusterHealthStatusReason = params => {
|
|
17
10
|
return new ClusterHealthReason(params);
|
|
18
11
|
};
|
|
19
|
-
exports.createClusterHealthStatusReason = createClusterHealthStatusReason;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=ClusterHealthReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ClusterHealthReason","name","constructor","params","minimum","current","description","
|
|
1
|
+
{"version":3,"names":["ClusterHealthReason","name","constructor","params","minimum","current","description","createClusterHealthStatusReason"],"sources":["ClusterHealthReason.ts"],"sourcesContent":["import type { ElasticsearchCatClusterHealthStatus } from \"~/operations/index.js\";\nimport type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IClusterHealthReasonParams {\n minimum: ElasticsearchCatClusterHealthStatus;\n current: ElasticsearchCatClusterHealthStatus;\n description?: string;\n}\n\nexport class ClusterHealthReason implements IReason {\n public readonly name = \"clusterHealth\";\n public readonly minimum: ElasticsearchCatClusterHealthStatus;\n public readonly current: ElasticsearchCatClusterHealthStatus;\n public readonly description?: string;\n\n public constructor(params: IClusterHealthReasonParams) {\n this.minimum = params.minimum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createClusterHealthStatusReason = (\n params: IClusterHealthReasonParams\n): ClusterHealthReason => {\n return new ClusterHealthReason(params);\n};\n"],"mappings":"AASA,OAAO,MAAMA,mBAAmB,CAAoB;EAChCC,IAAI,GAAG,eAAe;EAK/BC,WAAWA,CAACC,MAAkC,EAAE;IACnD,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,+BAA+B,GACxCJ,MAAkC,IACZ;EACtB,OAAO,IAAIH,mBAAmB,CAACG,MAAM,CAAC;AAC1C,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createMemoryReason = exports.MemoryReason = void 0;
|
|
7
|
-
class MemoryReason {
|
|
1
|
+
export class MemoryReason {
|
|
8
2
|
name = "memory";
|
|
9
3
|
constructor(params) {
|
|
10
4
|
this.maximum = params.maximum;
|
|
@@ -12,10 +6,8 @@ class MemoryReason {
|
|
|
12
6
|
this.description = params.description;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createMemoryReason = params => {
|
|
9
|
+
export const createMemoryReason = params => {
|
|
17
10
|
return new MemoryReason(params);
|
|
18
11
|
};
|
|
19
|
-
exports.createMemoryReason = createMemoryReason;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=MemoryReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MemoryReason","name","constructor","params","maximum","current","description","
|
|
1
|
+
{"version":3,"names":["MemoryReason","name","constructor","params","maximum","current","description","createMemoryReason"],"sources":["MemoryReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IMemoryReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class MemoryReason implements IReason {\n public readonly name = \"memory\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IMemoryReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createMemoryReason = (params: IMemoryReasonParams): MemoryReason => {\n return new MemoryReason(params);\n};\n"],"mappings":"AAQA,OAAO,MAAMA,YAAY,CAAoB;EACzBC,IAAI,GAAG,QAAQ;EAKxBC,WAAWA,CAACC,MAA2B,EAAE;IAC5C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAIJ,MAA2B,IAAmB;EAC7E,OAAO,IAAIH,YAAY,CAACG,MAAM,CAAC;AACnC,CAAC","ignoreList":[]}
|