@webiny/api-opensearch 0.0.0-unstable.e6f0dc8ca7 → 0.0.0-unstable.eb81deee7e
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/client.js +30 -63
- package/client.js.map +1 -1
- package/cursors.js +20 -32
- package/cursors.js.map +1 -1
- package/exports/api/opensearch.d.ts +6 -1
- package/exports/api/opensearch.js +6 -3
- package/features/OpenSearchClient/abstraction.d.ts +3 -3
- package/features/OpenSearchClient/abstraction.js +2 -1
- package/features/OpenSearchClient/abstraction.js.map +1 -1
- package/features/OpenSearchClient/feature.d.ts +2 -1
- package/features/OpenSearchClient/feature.js +9 -6
- package/features/OpenSearchClient/feature.js.map +1 -1
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
- package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
- package/features/OpenSearchClientFactory/abstraction.js +2 -1
- package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
- package/features/OpenSearchClientFactory/feature.js +6 -5
- package/features/OpenSearchClientFactory/feature.js.map +1 -1
- package/features/OpenSearchField/OpenSearchField.d.ts +18 -0
- package/features/OpenSearchField/OpenSearchField.js +49 -0
- package/features/OpenSearchField/OpenSearchField.js.map +1 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.d.ts +9 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.js +14 -0
- package/features/OpenSearchField/OpenSearchFieldFactory.js.map +1 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.d.ts +35 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.js +6 -0
- package/features/OpenSearchField/abstractions/OpenSearchField.js.map +1 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.d.ts +8 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js +5 -0
- package/features/OpenSearchField/abstractions/OpenSearchFieldFactory.js.map +1 -0
- package/features/OpenSearchField/feature.d.ts +4 -0
- package/features/OpenSearchField/feature.js +11 -0
- package/features/OpenSearchField/feature.js.map +1 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.d.ts +12 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.js +30 -0
- package/features/OpenSearchIndex/OpenSearchIndexRegistry.js.map +1 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.d.ts +9 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js +5 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndex.js.map +1 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.d.ts +9 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js +5 -0
- package/features/OpenSearchIndex/abstractions/OpenSearchIndexRegistry.js.map +1 -0
- package/features/OpenSearchIndex/feature.d.ts +4 -0
- package/features/OpenSearchIndex/feature.js +11 -0
- package/features/OpenSearchIndex/feature.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.d.ts +12 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js +28 -0
- package/features/OpenSearchQueryBuilderOperator/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.d.ts +11 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js +5 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperator.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.d.ts +10 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js +5 -0
- package/features/OpenSearchQueryBuilderOperator/abstractions/OpenSearchQueryBuilderOperatorRegistry.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/feature.d.ts +4 -0
- package/features/OpenSearchQueryBuilderOperator/feature.js +41 -0
- package/features/OpenSearchQueryBuilderOperator/feature.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js +28 -0
- package/features/OpenSearchQueryBuilderOperator/operators/AndIn.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Between.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Contains.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.js +34 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Equal.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThan.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/GreaterThanOrEqual.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.js +24 -0
- package/features/OpenSearchQueryBuilderOperator/operators/In.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThan.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js +23 -0
- package/features/OpenSearchQueryBuilderOperator/operators/LesserThanOrEqual.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.js +38 -0
- package/features/OpenSearchQueryBuilderOperator/operators/Not.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotBetween.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js +27 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotContains.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js +24 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotIn.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js +22 -0
- package/features/OpenSearchQueryBuilderOperator/operators/NotStartsWith.js.map +1 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.d.ts +9 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js +22 -0
- package/features/OpenSearchQueryBuilderOperator/operators/StartsWith.js.map +1 -0
- package/index.d.ts +2 -10
- package/index.js +3 -30
- package/indexConfiguration/base.js +25 -26
- package/indexConfiguration/base.js.map +1 -1
- package/indexConfiguration/common.js +39 -41
- package/indexConfiguration/common.js.map +1 -1
- package/indexConfiguration/index.js +0 -2
- package/indexPrefix.js +2 -3
- package/indexPrefix.js.map +1 -1
- package/indices.d.ts +2 -8
- package/indices.js +1 -20
- package/limit.js +5 -27
- package/limit.js.map +1 -1
- package/normalize.js +50 -49
- package/normalize.js.map +1 -1
- package/operations/OpenSearchCatHealth.js +24 -25
- package/operations/OpenSearchCatHealth.js.map +1 -1
- package/operations/OpenSearchCatNodes.js +22 -23
- package/operations/OpenSearchCatNodes.js.map +1 -1
- package/operations/index.js +0 -2
- package/operations/stripConnectionFromException.js +11 -14
- package/operations/stripConnectionFromException.js.map +1 -1
- package/operations/types.js +6 -5
- package/operations/types.js.map +1 -1
- package/package.json +12 -14
- package/registerOpenSearchCore.d.ts +3 -0
- package/registerOpenSearchCore.js +20 -0
- package/registerOpenSearchCore.js.map +1 -0
- package/sharedIndex.js +2 -3
- package/sharedIndex.js.map +1 -1
- package/sort.d.ts +2 -2
- package/sort.js +30 -59
- package/sort.js.map +1 -1
- package/testing/createBlankQuery.d.ts +2 -0
- package/testing/createBlankQuery.js +9 -0
- package/testing/createBlankQuery.js.map +1 -0
- package/testing/createTestOpenSearchClient.d.ts +11 -0
- package/testing/createTestOpenSearchClient.js +162 -0
- package/testing/createTestOpenSearchClient.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.js +4 -0
- package/testing/registerOpenSearchCoreForTests.d.ts +1 -0
- package/testing/registerOpenSearchCoreForTests.js +9 -0
- package/testing/registerOpenSearchCoreForTests.js.map +1 -0
- package/testing/setupTestIndexManager.d.ts +13 -0
- package/testing/setupTestIndexManager.js +26 -0
- package/testing/setupTestIndexManager.js.map +1 -0
- package/types.d.ts +0 -8
- package/types.js +5 -65
- package/types.js.map +1 -1
- package/utils/createIndex.d.ts +2 -2
- package/utils/createIndex.js +52 -80
- package/utils/createIndex.js.map +1 -1
- package/utils/index.js +0 -2
- package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
- package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
- package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
- package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
- package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
- package/utils/waitUntilHealthy/index.js +0 -2
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
- package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/IReason.js +0 -3
- package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
- package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
- package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
- package/utils/waitUntilHealthy/reason/index.js +0 -2
- package/where.d.ts +4 -4
- package/where.js +43 -76
- package/where.js.map +1 -1
- package/db/entity.d.ts +0 -7
- package/db/entity.js +0 -20
- package/db/entity.js.map +0 -1
- package/db/index.d.ts +0 -3
- package/db/index.js +0 -5
- package/db/index.js.map +0 -1
- package/db/table.d.ts +0 -7
- package/db/table.js +0 -17
- package/db/table.js.map +0 -1
- package/db/types.d.ts +0 -6
- package/db/types.js +0 -3
- package/db/types.js.map +0 -1
- package/exports/api/opensearch.js.map +0 -1
- package/features/OpenSearchClient/OpenSearchClient.d.ts +0 -12
- package/features/OpenSearchClient/OpenSearchClient.js +0 -16
- package/features/OpenSearchClient/OpenSearchClient.js.map +0 -1
- package/features/OpenSearchContext/OpenSearchContext.d.ts +0 -8
- package/features/OpenSearchContext/OpenSearchContext.js +0 -13
- package/features/OpenSearchContext/OpenSearchContext.js.map +0 -1
- package/features/OpenSearchContext/abstraction.d.ts +0 -14
- package/features/OpenSearchContext/abstraction.js +0 -4
- package/features/OpenSearchContext/abstraction.js.map +0 -1
- package/features/OpenSearchContext/feature.d.ts +0 -5
- package/features/OpenSearchContext/feature.js +0 -13
- package/features/OpenSearchContext/feature.js.map +0 -1
- package/index.js.map +0 -1
- package/indexConfiguration/index.js.map +0 -1
- package/indices.js.map +0 -1
- package/operations/index.js.map +0 -1
- package/operators.d.ts +0 -6
- package/operators.js +0 -9
- package/operators.js.map +0 -1
- package/plugins/definition/OpenSearchBodyModifierPlugin.d.ts +0 -13
- package/plugins/definition/OpenSearchBodyModifierPlugin.js +0 -18
- package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchFieldPlugin.d.ts +0 -81
- package/plugins/definition/OpenSearchFieldPlugin.js +0 -69
- package/plugins/definition/OpenSearchFieldPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchIndexPlugin.d.ts +0 -10
- package/plugins/definition/OpenSearchIndexPlugin.js +0 -17
- package/plugins/definition/OpenSearchIndexPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.d.ts +0 -10
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +0 -9
- package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchQueryModifierPlugin.d.ts +0 -14
- package/plugins/definition/OpenSearchQueryModifierPlugin.js +0 -18
- package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +0 -1
- package/plugins/definition/OpenSearchSortModifierPlugin.d.ts +0 -13
- package/plugins/definition/OpenSearchSortModifierPlugin.js +0 -18
- package/plugins/definition/OpenSearchSortModifierPlugin.js.map +0 -1
- package/plugins/definition/index.d.ts +0 -6
- package/plugins/definition/index.js +0 -8
- package/plugins/definition/index.js.map +0 -1
- package/plugins/index.d.ts +0 -2
- package/plugins/index.js +0 -4
- package/plugins/index.js.map +0 -1
- package/plugins/operator/andIn.d.ts +0 -7
- package/plugins/operator/andIn.js +0 -35
- package/plugins/operator/andIn.js.map +0 -1
- package/plugins/operator/between.d.ts +0 -7
- package/plugins/operator/between.js +0 -32
- package/plugins/operator/between.js.map +0 -1
- package/plugins/operator/contains.d.ts +0 -7
- package/plugins/operator/contains.js +0 -24
- package/plugins/operator/contains.js.map +0 -1
- package/plugins/operator/equal.d.ts +0 -7
- package/plugins/operator/equal.js +0 -50
- package/plugins/operator/equal.js.map +0 -1
- package/plugins/operator/gt.d.ts +0 -7
- package/plugins/operator/gt.js +0 -22
- package/plugins/operator/gt.js.map +0 -1
- package/plugins/operator/gte.d.ts +0 -7
- package/plugins/operator/gte.js +0 -22
- package/plugins/operator/gte.js.map +0 -1
- package/plugins/operator/in.d.ts +0 -7
- package/plugins/operator/in.js +0 -29
- package/plugins/operator/in.js.map +0 -1
- package/plugins/operator/index.d.ts +0 -15
- package/plugins/operator/index.js +0 -17
- package/plugins/operator/index.js.map +0 -1
- package/plugins/operator/lt.d.ts +0 -7
- package/plugins/operator/lt.js +0 -22
- package/plugins/operator/lt.js.map +0 -1
- package/plugins/operator/lte.d.ts +0 -7
- package/plugins/operator/lte.js +0 -22
- package/plugins/operator/lte.js.map +0 -1
- package/plugins/operator/not.d.ts +0 -7
- package/plugins/operator/not.js +0 -44
- package/plugins/operator/not.js.map +0 -1
- package/plugins/operator/notBetween.d.ts +0 -7
- package/plugins/operator/notBetween.js +0 -32
- package/plugins/operator/notBetween.js.map +0 -1
- package/plugins/operator/notContains.d.ts +0 -7
- package/plugins/operator/notContains.js +0 -24
- package/plugins/operator/notContains.js.map +0 -1
- package/plugins/operator/notIn.d.ts +0 -7
- package/plugins/operator/notIn.js +0 -27
- package/plugins/operator/notIn.js.map +0 -1
- package/plugins/operator/notStartsWith.d.ts +0 -7
- package/plugins/operator/notStartsWith.js +0 -23
- package/plugins/operator/notStartsWith.js.map +0 -1
- package/plugins/operator/startsWith.d.ts +0 -7
- package/plugins/operator/startsWith.js +0 -23
- package/plugins/operator/startsWith.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/waitUntilHealthy/index.js.map +0 -1
- package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
- package/utils/waitUntilHealthy/reason/index.js.map +0 -1
package/utils/createIndex.js
CHANGED
|
@@ -1,88 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
if (!response.body) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (onExists) {
|
|
22
|
-
onExists();
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
|
+
const indexExists = async (params)=>{
|
|
3
|
+
const { client, index } = params;
|
|
4
|
+
try {
|
|
5
|
+
const response = await client.indices.exists({
|
|
6
|
+
index,
|
|
7
|
+
ignore_unavailable: false,
|
|
8
|
+
allow_no_indices: true,
|
|
9
|
+
include_defaults: true,
|
|
10
|
+
flat_settings: false,
|
|
11
|
+
local: false
|
|
12
|
+
});
|
|
13
|
+
if (!response.body) return false;
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
console.error(`Could not determine if the index "${index}" exists.`);
|
|
23
17
|
}
|
|
24
|
-
return
|
|
25
|
-
} catch {
|
|
26
|
-
console.error(`Could not determine if the index "${index}" exists.`);
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
18
|
+
return false;
|
|
29
19
|
};
|
|
30
|
-
const indexCreate = async params
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
const indexCreate = async (params)=>{
|
|
21
|
+
const { client, index, plugin, tenant, type, onError } = params;
|
|
22
|
+
try {
|
|
23
|
+
await client.indices.create({
|
|
24
|
+
index,
|
|
25
|
+
body: {
|
|
26
|
+
...plugin.body
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
} catch (ex) {
|
|
30
|
+
let error = ex;
|
|
31
|
+
if (onError) error = onError(ex);
|
|
32
|
+
throw new _webiny_error(error.message || `Could not create OpenSearch index for the ${type}.`, error.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
|
|
33
|
+
error: {
|
|
34
|
+
...error,
|
|
35
|
+
message: error.message,
|
|
36
|
+
code: error.code,
|
|
37
|
+
data: error.data
|
|
38
|
+
},
|
|
39
|
+
type,
|
|
40
|
+
tenant,
|
|
41
|
+
index,
|
|
42
|
+
body: plugin.body
|
|
43
|
+
});
|
|
50
44
|
}
|
|
51
|
-
throw new WebinyError(error.message || `Could not create OpenSearch index for the ${type}.`, error.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
|
|
52
|
-
error: {
|
|
53
|
-
...error,
|
|
54
|
-
message: error.message,
|
|
55
|
-
code: error.code,
|
|
56
|
-
data: error.data
|
|
57
|
-
},
|
|
58
|
-
type,
|
|
59
|
-
tenant,
|
|
60
|
-
index,
|
|
61
|
-
body: plugin.body
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
45
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const plugin = getLastAddedIndexPlugin({
|
|
72
|
-
container: plugins,
|
|
73
|
-
type
|
|
74
|
-
});
|
|
75
|
-
const exists = await indexExists(params);
|
|
76
|
-
if (exists) {
|
|
77
|
-
if (onExists) {
|
|
78
|
-
onExists();
|
|
46
|
+
const createIndex = async (params)=>{
|
|
47
|
+
const { plugin, onExists } = params;
|
|
48
|
+
const exists = await indexExists(params);
|
|
49
|
+
if (exists) {
|
|
50
|
+
if (onExists) onExists();
|
|
51
|
+
return;
|
|
79
52
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
plugin
|
|
85
|
-
});
|
|
53
|
+
await indexCreate({
|
|
54
|
+
...params,
|
|
55
|
+
plugin
|
|
56
|
+
});
|
|
86
57
|
};
|
|
58
|
+
export { createIndex };
|
|
87
59
|
|
|
88
60
|
//# sourceMappingURL=createIndex.js.map
|
package/utils/createIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/createIndex.js","sources":["../../src/utils/createIndex.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport type { OpenSearchIndex } from \"~/features/OpenSearchIndex/abstractions/OpenSearchIndex.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}\n\nconst indexExists = async (params: ExistsIndexParams): Promise<boolean> => {\n const { client, index } = 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 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: OpenSearchIndex.Interface;\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 OpenSearch 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 plugin: OpenSearchIndex.Interface;\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 { plugin, onExists } = params;\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"],"names":["indexExists","params","client","index","response","console","indexCreate","plugin","tenant","type","onError","ex","error","WebinyError","createIndex","onExists","exists"],"mappings":";AAiBA,MAAMA,cAAc,OAAOC;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGF;IAE1B,IAAI;QACA,MAAMG,WAAW,MAAMF,OAAO,OAAO,CAAC,MAAM,CAAC;YACzCC;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,IAAI,CAACC,SAAS,IAAI,EACd,OAAO;QAEX,OAAO;IACX,EAAE,OAAM;QACJC,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEF,MAAM,SAAS,CAAC;IACvE;IACA,OAAO;AACX;AAWA,MAAMG,cAAc,OAAOL;IACvB,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEI,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAE,GAAGT;IAEzD,IAAI;QACA,MAAMC,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBC;YACA,MAAM;gBACF,GAAGI,OAAO,IAAI;YAClB;QACJ;IACJ,EAAE,OAAOI,IAAI;QACT,IAAIC,QAAQD;QACZ,IAAID,SACAE,QAAQF,QAAQC;QAEpB,MAAM,IAAIE,cACND,MAAM,OAAO,IAAI,CAAC,0CAA0C,EAAEH,KAAK,CAAC,CAAC,EACrEG,MAAM,IAAI,IAAI,iCACd;YACI,OAAO;gBACH,GAAGA,KAAK;gBACR,SAASA,MAAM,OAAO;gBACtB,MAAMA,MAAM,IAAI;gBAChB,MAAMA,MAAM,IAAI;YACpB;YACAH;YACAD;YACAL;YACA,MAAMI,OAAO,IAAI;QACrB;IAER;AACJ;AAYO,MAAMO,cAAc,OAAOb;IAC9B,MAAM,EAAEM,MAAM,EAAEQ,QAAQ,EAAE,GAAGd;IAE7B,MAAMe,SAAS,MAAMhB,YAAYC;IACjC,IAAIe,QAAQ;QACR,IAAID,UACAA;QAEJ;IACJ;IAEA,MAAMT,YAAY;QACd,GAAGL,MAAM;QACTM;IACJ;AACJ"}
|
package/utils/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
class UnhealthyClusterError extends WebinyError {
|
|
3
|
+
constructor(maxWaitingTime){
|
|
4
|
+
super({
|
|
5
|
+
message: `Cluster did not become healthy in ${maxWaitingTime} seconds.`,
|
|
6
|
+
code: "UNHEALTHY_CLUSTER"
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
+
export { UnhealthyClusterError };
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=UnhealthyClusterError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/waitUntilHealthy/UnhealthyClusterError.js","sources":["../../../src/utils/waitUntilHealthy/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"],"names":["UnhealthyClusterError","WebinyError","maxWaitingTime"],"mappings":";AAEO,MAAMA,8BAA8BC;IACvC,YAAmBC,cAAsB,CAAE;QACvC,KAAK,CAAC;YACF,SAAS,CAAC,kCAAkC,EAAEA,eAAe,SAAS,CAAC;YACvE,MAAM;QACV;IACJ;AACJ"}
|
|
@@ -6,156 +6,126 @@ import { createClusterHealthStatusReason, createMemoryReason, createProcessorRea
|
|
|
6
6
|
import { WaitingHealthyClusterAbortedError } from "./WaitingHealthyClusterAbortedError.js";
|
|
7
7
|
const WAITING_TIME_STEP = 10;
|
|
8
8
|
class WaitUntilHealthy {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
abort() {
|
|
17
|
-
this.aborted = true;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @throws UnhealthyClusterError
|
|
21
|
-
* @throws WaitingHealthyClusterAbortedError
|
|
22
|
-
*/
|
|
23
|
-
async wait(options) {
|
|
24
|
-
if (this.aborted) {
|
|
25
|
-
throw new WaitingHealthyClusterAbortedError(`Waiting for the cluster to become healthy was aborted even before it started.`);
|
|
9
|
+
constructor(client, options){
|
|
10
|
+
this.aborted = false;
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.catHealth = new OpenSearchCatHealth(this.client);
|
|
14
|
+
this.catNodes = new OpenSearchCatNodes(this.client);
|
|
26
15
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
abort() {
|
|
17
|
+
this.aborted = true;
|
|
18
|
+
}
|
|
19
|
+
async wait(options) {
|
|
20
|
+
if (this.aborted) throw new WaitingHealthyClusterAbortedError("Waiting for the cluster to become healthy was aborted even before it started.");
|
|
21
|
+
const startedAt = new Date();
|
|
22
|
+
const mustEndAt = new Date(startedAt.getTime() + 1000 * this.options.maxWaitingTime);
|
|
23
|
+
const waitingTimeStep = this.options.waitingTimeStep || WAITING_TIME_STEP;
|
|
24
|
+
let runs = 1;
|
|
25
|
+
let waitingReason;
|
|
26
|
+
while(waitingReason = await this.shouldWait()){
|
|
27
|
+
if (new Date() >= mustEndAt) {
|
|
28
|
+
if (options?.onTimeout) await options.onTimeout({
|
|
29
|
+
startedAt,
|
|
30
|
+
mustEndAt,
|
|
31
|
+
waitingTimeStep,
|
|
32
|
+
waitingReason,
|
|
33
|
+
runs
|
|
34
|
+
});
|
|
35
|
+
throw new UnhealthyClusterError(this.options.maxWaitingTime);
|
|
36
|
+
}
|
|
37
|
+
if (options?.onUnhealthy) await options.onUnhealthy({
|
|
38
|
+
startedAt,
|
|
39
|
+
mustEndAt,
|
|
40
|
+
waitingTimeStep,
|
|
41
|
+
waitingReason,
|
|
42
|
+
runs
|
|
43
|
+
});
|
|
44
|
+
if (this.aborted) throw new WaitingHealthyClusterAbortedError();
|
|
45
|
+
runs++;
|
|
46
|
+
await new Promise((resolve)=>{
|
|
47
|
+
setTimeout(resolve, 1000 * waitingTimeStep);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const runningTime = new Date().getTime() - startedAt.getTime();
|
|
51
|
+
return {
|
|
52
|
+
runningTime,
|
|
40
53
|
runs
|
|
41
|
-
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async shouldWait() {
|
|
57
|
+
let health;
|
|
58
|
+
let nodes;
|
|
59
|
+
try {
|
|
60
|
+
health = await this.catHealth.getHealth();
|
|
61
|
+
} catch (ex) {
|
|
62
|
+
return createClusterHealthStatusReason({
|
|
63
|
+
description: ex.message,
|
|
64
|
+
minimum: this.options.minClusterHealthStatus,
|
|
65
|
+
current: OpenSearchCatClusterHealthStatus.Red
|
|
66
|
+
});
|
|
42
67
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
try {
|
|
69
|
+
nodes = await this.catNodes.getNodes();
|
|
70
|
+
} catch (ex) {
|
|
71
|
+
return createClusterHealthStatusReason({
|
|
72
|
+
description: ex.message,
|
|
73
|
+
minimum: this.options.minClusterHealthStatus,
|
|
74
|
+
current: OpenSearchCatClusterHealthStatus.Red
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const currentStatus = this.toClusterHealthStatus(health.status);
|
|
78
|
+
const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);
|
|
79
|
+
const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
|
|
80
|
+
if (clusterHealthStatus > minClusterHealthStatus) return createClusterHealthStatusReason({
|
|
81
|
+
minimum: this.options.minClusterHealthStatus,
|
|
82
|
+
current: currentStatus
|
|
51
83
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const runningTime = new Date().getTime() - startedAt.getTime();
|
|
65
|
-
return {
|
|
66
|
-
runningTime,
|
|
67
|
-
runs
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async shouldWait() {
|
|
71
|
-
let health;
|
|
72
|
-
let nodes;
|
|
73
|
-
try {
|
|
74
|
-
health = await this.catHealth.getHealth();
|
|
75
|
-
} catch (ex) {
|
|
76
|
-
return createClusterHealthStatusReason({
|
|
77
|
-
description: ex.message,
|
|
78
|
-
minimum: this.options.minClusterHealthStatus,
|
|
79
|
-
current: OpenSearchCatClusterHealthStatus.Red
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
nodes = await this.catNodes.getNodes();
|
|
84
|
-
} catch (ex) {
|
|
85
|
-
return createClusterHealthStatusReason({
|
|
86
|
-
description: ex.message,
|
|
87
|
-
minimum: this.options.minClusterHealthStatus,
|
|
88
|
-
current: OpenSearchCatClusterHealthStatus.Red
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
const currentStatus = this.toClusterHealthStatus(health.status);
|
|
92
|
-
const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);
|
|
93
|
-
const minClusterHealthStatus = this.transformClusterHealthStatus(this.options.minClusterHealthStatus);
|
|
94
|
-
if (clusterHealthStatus > minClusterHealthStatus) {
|
|
95
|
-
return createClusterHealthStatusReason({
|
|
96
|
-
minimum: this.options.minClusterHealthStatus,
|
|
97
|
-
current: currentStatus
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const processorPercent = this.getProcessorPercent(nodes);
|
|
101
|
-
if (processorPercent > this.options.maxProcessorPercent) {
|
|
102
|
-
return createProcessorReason({
|
|
103
|
-
maximum: this.options.maxProcessorPercent,
|
|
104
|
-
current: processorPercent
|
|
105
|
-
});
|
|
84
|
+
const processorPercent = this.getProcessorPercent(nodes);
|
|
85
|
+
if (processorPercent > this.options.maxProcessorPercent) return createProcessorReason({
|
|
86
|
+
maximum: this.options.maxProcessorPercent,
|
|
87
|
+
current: processorPercent
|
|
88
|
+
});
|
|
89
|
+
if (void 0 === this.options.maxRamPercent) return false;
|
|
90
|
+
const ramPercent = this.getRamPercent(nodes);
|
|
91
|
+
if (ramPercent > this.options.maxRamPercent) return createMemoryReason({
|
|
92
|
+
maximum: this.options.maxRamPercent,
|
|
93
|
+
current: ramPercent
|
|
94
|
+
});
|
|
95
|
+
return false;
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (this.options.maxRamPercent === undefined) {
|
|
111
|
-
return false;
|
|
97
|
+
getProcessorPercent(nodes) {
|
|
98
|
+
const total = nodes.reduce((total, node)=>total + parseFloat(node.cpu || "0"), 0);
|
|
99
|
+
return total / nodes.length;
|
|
112
100
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
maximum: this.options.maxRamPercent,
|
|
117
|
-
current: ramPercent
|
|
118
|
-
});
|
|
101
|
+
getRamPercent(nodes) {
|
|
102
|
+
const total = nodes.reduce((total, node)=>total + parseFloat(node["ram.percent"] || "0"), 0);
|
|
103
|
+
return total / nodes.length;
|
|
119
104
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const total = nodes.reduce((total, node) => {
|
|
130
|
-
return total + parseFloat(node["ram.percent"] || "0");
|
|
131
|
-
}, 0);
|
|
132
|
-
return total / nodes.length;
|
|
133
|
-
}
|
|
134
|
-
toClusterHealthStatus(status) {
|
|
135
|
-
switch (status) {
|
|
136
|
-
case "green":
|
|
137
|
-
return OpenSearchCatClusterHealthStatus.Green;
|
|
138
|
-
case "yellow":
|
|
139
|
-
return OpenSearchCatClusterHealthStatus.Yellow;
|
|
140
|
-
default:
|
|
141
|
-
return OpenSearchCatClusterHealthStatus.Red;
|
|
105
|
+
toClusterHealthStatus(status) {
|
|
106
|
+
switch(status){
|
|
107
|
+
case "green":
|
|
108
|
+
return OpenSearchCatClusterHealthStatus.Green;
|
|
109
|
+
case "yellow":
|
|
110
|
+
return OpenSearchCatClusterHealthStatus.Yellow;
|
|
111
|
+
default:
|
|
112
|
+
return OpenSearchCatClusterHealthStatus.Red;
|
|
113
|
+
}
|
|
142
114
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
115
|
+
transformClusterHealthStatus(status) {
|
|
116
|
+
switch(status){
|
|
117
|
+
case OpenSearchCatClusterHealthStatus.Green:
|
|
118
|
+
return 1;
|
|
119
|
+
case OpenSearchCatClusterHealthStatus.Yellow:
|
|
120
|
+
return 2;
|
|
121
|
+
case OpenSearchCatClusterHealthStatus.Red:
|
|
122
|
+
return 3;
|
|
123
|
+
default:
|
|
124
|
+
return 99;
|
|
125
|
+
}
|
|
154
126
|
}
|
|
155
|
-
}
|
|
156
127
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
128
|
+
const createWaitUntilHealthy = (client, params)=>new WaitUntilHealthy(client, params);
|
|
129
|
+
export { createWaitUntilHealthy };
|
|
160
130
|
|
|
161
131
|
//# sourceMappingURL=WaitUntilHealthy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OpenSearchCatHealth","OpenSearchCatNodes","OpenSearchCatClusterHealthStatus","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","currentStatus","toClusterHealthStatus","status","clusterHealthStatus","transformClusterHealthStatus","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 { OpenSearchCatHealth } from \"~/operations/OpenSearchCatHealth.js\";\nimport { OpenSearchCatNodes } from \"~/operations/OpenSearchCatNodes.js\";\nimport type {\n IOpenSearchCatHealthResponse,\n IOpenSearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { OpenSearchCatClusterHealthStatus } 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 | OpenSearchCatClusterHealthStatus.Green\n | OpenSearchCatClusterHealthStatus.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: OpenSearchCatHealth;\n private readonly catNodes: OpenSearchCatNodes;\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 OpenSearchCatHealth(this.client);\n this.catNodes = new OpenSearchCatNodes(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: IOpenSearchCatHealthResponse;\n let nodes: IOpenSearchCatNodesResponse;\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: OpenSearchCatClusterHealthStatus.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: OpenSearchCatClusterHealthStatus.Red\n });\n }\n\n const currentStatus = this.toClusterHealthStatus(health.status);\n const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: currentStatus\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: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"] || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private toClusterHealthStatus(status?: string): OpenSearchCatClusterHealthStatus {\n switch (status) {\n case \"green\":\n return OpenSearchCatClusterHealthStatus.Green;\n case \"yellow\":\n return OpenSearchCatClusterHealthStatus.Yellow;\n default:\n return OpenSearchCatClusterHealthStatus.Red;\n }\n }\n\n private transformClusterHealthStatus(status: OpenSearchCatClusterHealthStatus): number {\n switch (status) {\n case OpenSearchCatClusterHealthStatus.Green:\n return 1;\n case OpenSearchCatClusterHealthStatus.Yellow:\n return 2;\n case OpenSearchCatClusterHealthStatus.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,mBAAmB;AAC5B,SAASC,kBAAkB;AAK3B,SAASC,gCAAgC;AACzC,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,WAAW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GAAGvB,KAAK,CAAC4B,MAAM;EAC/B;EAEQN,aAAaA,CAACtB,KAAkC,EAAU;IAC9D,MAAMuB,KAAK,GAAGvB,KAAK,CAACwB,MAAM,CAAS,CAACD,KAAK,EAAEE,IAAI,KAAK;MAChD,OAAOF,KAAK,GAAGG,UAAU,CAACD,IAAI,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC;IACzD,CAAC,EAAE,CAAC,CAAC;IACL,OAAOF,KAAK,GAAGvB,KAAK,CAAC4B,MAAM;EAC/B;EAEQjB,qBAAqBA,CAACC,MAAe,EAAoC;IAC7E,QAAQA,MAAM;MACV,KAAK,OAAO;QACR,OAAO5C,gCAAgC,CAAC6D,KAAK;MACjD,KAAK,QAAQ;QACT,OAAO7D,gCAAgC,CAAC8D,MAAM;MAClD;QACI,OAAO9D,gCAAgC,CAACwC,GAAG;IACnD;EACJ;EAEQM,4BAA4BA,CAACF,MAAwC,EAAU;IACnF,QAAQA,MAAM;MACV,KAAK5C,gCAAgC,CAAC6D,KAAK;QACvC,OAAO,CAAC;MACZ,KAAK7D,gCAAgC,CAAC8D,MAAM;QACxC,OAAO,CAAC;MACZ,KAAK9D,gCAAgC,CAACwC,GAAG;QACrC,OAAO,CAAC;MACZ;QACI,OAAO,EAAE;IACjB;EACJ;AACJ;AAIA,OAAO,MAAMuB,sBAAsB,GAAGA,CAClCrD,MAAc,EACdsD,MAA+B,KACZ;EACnB,OAAO,IAAIzD,gBAAgB,CAACG,MAAM,EAAEsD,MAAM,CAAC;AAC/C,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"utils/waitUntilHealthy/WaitUntilHealthy.js","sources":["../../../src/utils/waitUntilHealthy/WaitUntilHealthy.ts"],"sourcesContent":["import type { Client } from \"~/client.js\";\nimport { OpenSearchCatHealth } from \"~/operations/OpenSearchCatHealth.js\";\nimport { OpenSearchCatNodes } from \"~/operations/OpenSearchCatNodes.js\";\nimport type {\n IOpenSearchCatHealthResponse,\n IOpenSearchCatNodesResponse\n} from \"~/operations/types.js\";\nimport { OpenSearchCatClusterHealthStatus } 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 | OpenSearchCatClusterHealthStatus.Green\n | OpenSearchCatClusterHealthStatus.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: OpenSearchCatHealth;\n private readonly catNodes: OpenSearchCatNodes;\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 OpenSearchCatHealth(this.client);\n this.catNodes = new OpenSearchCatNodes(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: IOpenSearchCatHealthResponse;\n let nodes: IOpenSearchCatNodesResponse;\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: OpenSearchCatClusterHealthStatus.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: OpenSearchCatClusterHealthStatus.Red\n });\n }\n\n const currentStatus = this.toClusterHealthStatus(health.status);\n const clusterHealthStatus = this.transformClusterHealthStatus(currentStatus);\n const minClusterHealthStatus = this.transformClusterHealthStatus(\n this.options.minClusterHealthStatus\n );\n if (clusterHealthStatus > minClusterHealthStatus) {\n return createClusterHealthStatusReason({\n minimum: this.options.minClusterHealthStatus,\n current: currentStatus\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: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node.cpu || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private getRamPercent(nodes: IOpenSearchCatNodesResponse): number {\n const total = nodes.reduce<number>((total, node) => {\n return total + parseFloat(node[\"ram.percent\"] || \"0\");\n }, 0);\n return total / nodes.length;\n }\n\n private toClusterHealthStatus(status?: string): OpenSearchCatClusterHealthStatus {\n switch (status) {\n case \"green\":\n return OpenSearchCatClusterHealthStatus.Green;\n case \"yellow\":\n return OpenSearchCatClusterHealthStatus.Yellow;\n default:\n return OpenSearchCatClusterHealthStatus.Red;\n }\n }\n\n private transformClusterHealthStatus(status: OpenSearchCatClusterHealthStatus): number {\n switch (status) {\n case OpenSearchCatClusterHealthStatus.Green:\n return 1;\n case OpenSearchCatClusterHealthStatus.Yellow:\n return 2;\n case OpenSearchCatClusterHealthStatus.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"],"names":["WAITING_TIME_STEP","WaitUntilHealthy","client","options","OpenSearchCatHealth","OpenSearchCatNodes","WaitingHealthyClusterAbortedError","startedAt","Date","mustEndAt","waitingTimeStep","runs","waitingReason","UnhealthyClusterError","Promise","resolve","setTimeout","runningTime","health","nodes","ex","createClusterHealthStatusReason","OpenSearchCatClusterHealthStatus","currentStatus","clusterHealthStatus","minClusterHealthStatus","processorPercent","createProcessorReason","undefined","ramPercent","createMemoryReason","total","node","parseFloat","status","createWaitUntilHealthy","params"],"mappings":";;;;;;AAiBA,MAAMA,oBAAoB;AA0D1B,MAAMC;IASF,YAAmBC,MAAc,EAAEC,OAAgC,CAAE;aAF7D,OAAO,GAAG;QAGd,IAAI,CAAC,MAAM,GAAGD;QACd,IAAI,CAAC,OAAO,GAAGC;QAEf,IAAI,CAAC,SAAS,GAAG,IAAIC,oBAAoB,IAAI,CAAC,MAAM;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAIC,mBAAmB,IAAI,CAAC,MAAM;IACtD;IAEO,QAAc;QACjB,IAAI,CAAC,OAAO,GAAG;IACnB;IAKA,MAAa,KAAKF,OAAsB,EAA0C;QAC9E,IAAI,IAAI,CAAC,OAAO,EACZ,MAAM,IAAIG,kCACN;QAGR,MAAMC,YAAY,IAAIC;QACtB,MAAMC,YAAY,IAAID,KAAKD,UAAU,OAAO,KAAK,AAA8B,OAA9B,IAAI,CAAC,OAAO,CAAC,cAAc;QAC5E,MAAMG,kBAAkB,IAAI,CAAC,OAAO,CAAC,eAAe,IAAIV;QACxD,IAAIW,OAAO;QACX,IAAIC;QACJ,MAAQA,gBAAgB,MAAM,IAAI,CAAC,UAAU,GAAK;YAC9C,IAAI,IAAIJ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AMa,yBAAyB,CAClCjC,QACAkC,SAEO,IAAInC,iBAAiBC,QAAQkC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
class WaitingHealthyClusterAbortedError extends WebinyError {
|
|
3
|
+
constructor(message){
|
|
4
|
+
super({
|
|
5
|
+
message: message || "Waiting for the cluster to become healthy was aborted.",
|
|
6
|
+
code: "WAITING_HEALTHY_CLUSTER_ABORTED"
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
+
export { WaitingHealthyClusterAbortedError };
|
|
10
11
|
|
|
11
12
|
//# sourceMappingURL=WaitingHealthyClusterAbortedError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js","sources":["../../../src/utils/waitUntilHealthy/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"],"names":["WaitingHealthyClusterAbortedError","WebinyError","message"],"mappings":";AAEO,MAAMA,0CAA0CC;IACnD,YAAmBC,OAAgB,CAAE;QACjC,KAAK,CAAC;YACF,SAASA,WAAW;YACpB,MAAM;QACV;IACJ;AACJ"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
class ClusterHealthReason {
|
|
2
|
+
constructor(params){
|
|
3
|
+
this.name = "clusterHealth";
|
|
4
|
+
this.minimum = params.minimum;
|
|
5
|
+
this.current = params.current;
|
|
6
|
+
this.description = params.description;
|
|
7
|
+
}
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
9
|
+
const createClusterHealthStatusReason = (params)=>new ClusterHealthReason(params);
|
|
10
|
+
export { ClusterHealthReason, createClusterHealthStatusReason };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=ClusterHealthReason.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/waitUntilHealthy/reason/ClusterHealthReason.js","sources":["../../../../src/utils/waitUntilHealthy/reason/ClusterHealthReason.ts"],"sourcesContent":["import type { OpenSearchCatClusterHealthStatus } from \"~/operations/index.js\";\nimport type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IClusterHealthReasonParams {\n minimum: OpenSearchCatClusterHealthStatus;\n current: OpenSearchCatClusterHealthStatus;\n description?: string;\n}\n\nexport class ClusterHealthReason implements IReason {\n public readonly name = \"clusterHealth\";\n public readonly minimum: OpenSearchCatClusterHealthStatus;\n public readonly current: OpenSearchCatClusterHealthStatus;\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"],"names":["ClusterHealthReason","params","createClusterHealthStatusReason"],"mappings":"AASO,MAAMA;IAMT,YAAmBC,MAAkC,CAAE;aALvC,IAAI,GAAG;QAMnB,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;IACzC;AACJ;AAEO,MAAMC,kCAAkC,CAC3CD,SAEO,IAAID,oBAAoBC"}
|