@webiny/api-dynamodb-to-elasticsearch 6.3.0 → 6.4.0-beta.1
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/NotEnoughRemainingTimeError.js +3 -1
- package/NotEnoughRemainingTimeError.js.map +1 -1
- package/Operations.js +38 -35
- package/Operations.js.map +1 -1
- package/OperationsBuilder.js +50 -88
- package/OperationsBuilder.js.map +1 -1
- package/SynchronizationBuilder.js +30 -33
- package/SynchronizationBuilder.js.map +1 -1
- package/eventHandler.js +23 -42
- package/eventHandler.js.map +1 -1
- package/execute.js +90 -129
- package/execute.js.map +1 -1
- package/executeWithRetry.js +30 -40
- package/executeWithRetry.js.map +1 -1
- package/helpers/getNumberEnvVariable.js +7 -9
- package/helpers/getNumberEnvVariable.js.map +1 -1
- package/helpers/shouldShowLogs.js +4 -8
- package/helpers/shouldShowLogs.js.map +1 -1
- package/index.js +0 -2
- package/marshall.js +8 -15
- package/marshall.js.map +1 -1
- package/package.json +10 -10
- package/types.js +0 -3
- package/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { WebinyError } from "@webiny/error";
|
|
2
|
-
|
|
2
|
+
class NotEnoughRemainingTimeError extends WebinyError {
|
|
3
|
+
}
|
|
4
|
+
export { NotEnoughRemainingTimeError };
|
|
3
5
|
|
|
4
6
|
//# sourceMappingURL=NotEnoughRemainingTimeError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"NotEnoughRemainingTimeError.js","sources":["../src/NotEnoughRemainingTimeError.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\n\nexport class NotEnoughRemainingTimeError extends WebinyError {}\n"],"names":["NotEnoughRemainingTimeError","WebinyError"],"mappings":";AAEO,MAAMA,oCAAoCC;AAAa"}
|
package/Operations.js
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var Operations_OperationType = /*#__PURE__*/ function(OperationType) {
|
|
2
|
+
OperationType["INSERT"] = "INSERT";
|
|
3
|
+
OperationType["MODIFY"] = "MODIFY";
|
|
4
|
+
OperationType["REMOVE"] = "REMOVE";
|
|
5
|
+
return OperationType;
|
|
6
6
|
}({});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
7
|
+
class Operations {
|
|
8
|
+
get items() {
|
|
9
|
+
return this._items;
|
|
10
|
+
}
|
|
11
|
+
get total() {
|
|
12
|
+
return this.items.length;
|
|
13
|
+
}
|
|
14
|
+
clear() {
|
|
15
|
+
this._items = [];
|
|
16
|
+
}
|
|
17
|
+
insert(params) {
|
|
18
|
+
this.items.push({
|
|
19
|
+
index: {
|
|
20
|
+
_id: params.id,
|
|
21
|
+
_index: params.index
|
|
22
|
+
}
|
|
23
|
+
}, params.data);
|
|
24
|
+
}
|
|
25
|
+
modify(params) {
|
|
26
|
+
this.insert(params);
|
|
27
|
+
}
|
|
28
|
+
delete(params) {
|
|
29
|
+
this.items.push({
|
|
30
|
+
delete: {
|
|
31
|
+
_id: params.id,
|
|
32
|
+
_index: params.index
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
constructor(){
|
|
37
|
+
this._items = [];
|
|
38
|
+
}
|
|
37
39
|
}
|
|
40
|
+
export { Operations, Operations_OperationType as OperationType };
|
|
38
41
|
|
|
39
42
|
//# sourceMappingURL=Operations.js.map
|
package/Operations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Operations.js","sources":["../src/Operations.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n IDeleteOperationParams,\n IInsertOperationParams,\n IModifyOperationParams,\n IOperations\n} from \"~/types.js\";\n\nexport enum OperationType {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\"\n}\n\nexport class Operations implements IOperations {\n private _items: GenericRecord[] = [];\n\n public get items(): GenericRecord[] {\n return this._items;\n }\n\n public get total(): number {\n return this.items.length;\n }\n\n public clear() {\n this._items = [];\n }\n\n public insert(params: IInsertOperationParams): void {\n this.items.push(\n {\n index: {\n _id: params.id,\n _index: params.index\n }\n },\n params.data\n );\n }\n\n public modify(params: IModifyOperationParams): void {\n this.insert(params);\n }\n\n public delete(params: IDeleteOperationParams): void {\n this.items.push({\n delete: {\n _id: params.id,\n _index: params.index\n }\n });\n }\n}\n"],"names":["OperationType","Operations","params"],"mappings":"AAQO,IAAKA,2BAAaA,WAAAA,GAAAA,SAAbA,aAAa;;;;WAAbA;;AAML,MAAMC;IAGT,IAAW,QAAyB;QAChC,OAAO,IAAI,CAAC,MAAM;IACtB;IAEA,IAAW,QAAgB;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;IAC5B;IAEO,QAAQ;QACX,IAAI,CAAC,MAAM,GAAG,EAAE;IACpB;IAEO,OAAOC,MAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,CAAC,IAAI,CACX;YACI,OAAO;gBACH,KAAKA,OAAO,EAAE;gBACd,QAAQA,OAAO,KAAK;YACxB;QACJ,GACAA,OAAO,IAAI;IAEnB;IAEO,OAAOA,MAA8B,EAAQ;QAChD,IAAI,CAAC,MAAM,CAACA;IAChB;IAEO,OAAOA,MAA8B,EAAQ;QAChD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACZ,QAAQ;gBACJ,KAAKA,OAAO,EAAE;gBACd,QAAQA,OAAO,KAAK;YACxB;QACJ;IACJ;;aArCQ,MAAM,GAAoB,EAAE;;AAsCxC"}
|
package/OperationsBuilder.js
CHANGED
|
@@ -1,94 +1,56 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OperationType, Operations } from "./Operations.js";
|
|
2
2
|
import { unmarshall } from "./marshall.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.error(`Could not get index from the new image, skipping event "${record.eventID}".`);
|
|
51
|
-
console.log({
|
|
52
|
-
newImage
|
|
53
|
-
});
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* We must decompress the data that is going into the Elasticsearch.
|
|
58
|
-
*/
|
|
59
|
-
const data = await this.compressor.decompress(newImage.data);
|
|
60
|
-
/**
|
|
61
|
-
* No point in writing null or undefined data into the Elasticsearch.
|
|
62
|
-
* This might happen on some error while decompressing. We will log it.
|
|
63
|
-
*
|
|
64
|
-
* Data should NEVER be null or undefined in the Elasticsearch DynamoDB table, unless it is a delete operations.
|
|
65
|
-
* If it is - it is a bug.
|
|
66
|
-
*/
|
|
67
|
-
if (data === undefined || data === null) {
|
|
68
|
-
console.error(`Could not get decompressed data, skipping ES operation "${record.eventName}", ID ${id}. Skipping...`);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
operations.insert({
|
|
72
|
-
id,
|
|
73
|
-
index: newImage.index,
|
|
74
|
-
data
|
|
75
|
-
});
|
|
76
|
-
} else if (record.eventName === OperationType.REMOVE) {
|
|
77
|
-
const oldImage = unmarshall(record.dynamodb.OldImage);
|
|
78
|
-
/**
|
|
79
|
-
* If there is no index found, silently continue to the next operation.
|
|
80
|
-
*/
|
|
81
|
-
if (!oldImage?.index) {
|
|
82
|
-
continue;
|
|
3
|
+
class OperationsBuilder {
|
|
4
|
+
constructor(params){
|
|
5
|
+
this.compressor = params.compressor;
|
|
6
|
+
}
|
|
7
|
+
async build(params) {
|
|
8
|
+
const operations = new Operations();
|
|
9
|
+
for (const record of params.records){
|
|
10
|
+
if (!record.dynamodb) continue;
|
|
11
|
+
if (!record.eventName) {
|
|
12
|
+
console.error(`Could not get operation from the record, skipping event "${record.eventID}".`);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
const keys = unmarshall(record.dynamodb.Keys);
|
|
16
|
+
if (!keys?.PK || !keys.SK) {
|
|
17
|
+
console.error(`Could not get keys from the record, skipping event "${record.eventID}".`);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const id = `${keys.PK}:${keys.SK}`;
|
|
21
|
+
if (record.eventName === OperationType.INSERT || record.eventName === OperationType.MODIFY) {
|
|
22
|
+
const newImage = unmarshall(record.dynamodb.NewImage);
|
|
23
|
+
if (!newImage || "object" != typeof newImage || 0 === Object.keys(newImage).length) continue;
|
|
24
|
+
if (true === newImage.ignore) continue;
|
|
25
|
+
if (!newImage.index) {
|
|
26
|
+
console.error(`Could not get index from the new image, skipping event "${record.eventID}".`);
|
|
27
|
+
console.log({
|
|
28
|
+
newImage
|
|
29
|
+
});
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const data = await this.compressor.decompress(newImage.data);
|
|
33
|
+
if (null == data) {
|
|
34
|
+
console.error(`Could not get decompressed data, skipping ES operation "${record.eventName}", ID ${id}. Skipping...`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
operations.insert({
|
|
38
|
+
id,
|
|
39
|
+
index: newImage.index,
|
|
40
|
+
data
|
|
41
|
+
});
|
|
42
|
+
} else if (record.eventName === OperationType.REMOVE) {
|
|
43
|
+
const oldImage = unmarshall(record.dynamodb.OldImage);
|
|
44
|
+
if (!oldImage?.index) continue;
|
|
45
|
+
operations.delete({
|
|
46
|
+
id,
|
|
47
|
+
index: oldImage.index
|
|
48
|
+
});
|
|
49
|
+
}
|
|
83
50
|
}
|
|
84
|
-
operations
|
|
85
|
-
id,
|
|
86
|
-
index: oldImage.index
|
|
87
|
-
});
|
|
88
|
-
}
|
|
51
|
+
return operations;
|
|
89
52
|
}
|
|
90
|
-
return operations;
|
|
91
|
-
}
|
|
92
53
|
}
|
|
54
|
+
export { OperationsBuilder };
|
|
93
55
|
|
|
94
56
|
//# sourceMappingURL=OperationsBuilder.js.map
|
package/OperationsBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"OperationsBuilder.js","sources":["../src/OperationsBuilder.ts"],"sourcesContent":["import type { IOperations, IOperationsBuilder, IOperationsBuilderBuildParams } from \"./types.js\";\nimport { Operations, OperationType } from \"~/Operations.js\";\nimport { unmarshall } from \"~/marshall.js\";\nimport type { CompressionHandler } from \"@webiny/utils/exports/api.js\";\n\ninterface RecordDynamoDbImage {\n data: {\n compression: string;\n value: string;\n };\n ignore?: boolean;\n index: string;\n}\n\ninterface RecordDynamoDbKeys {\n PK: string;\n SK: string;\n}\n\nexport interface IOperationsBuilderParams {\n compressor: CompressionHandler.Interface;\n}\n\nexport class OperationsBuilder implements IOperationsBuilder {\n private readonly compressor: CompressionHandler.Interface;\n\n public constructor(params: IOperationsBuilderParams) {\n this.compressor = params.compressor;\n }\n\n public async build(params: IOperationsBuilderBuildParams): Promise<IOperations> {\n const operations = new Operations();\n for (const record of params.records) {\n if (!record.dynamodb) {\n continue;\n } else if (!record.eventName) {\n console.error(\n `Could not get operation from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const keys = unmarshall<RecordDynamoDbKeys>(record.dynamodb.Keys);\n if (!keys?.PK || !keys.SK) {\n console.error(\n `Could not get keys from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const id = `${keys.PK}:${keys.SK}`;\n\n /**\n * On operations other than REMOVE we decompress the data and store it into the Elasticsearch.\n * No need to try to decompress if operation is REMOVE since there is no data sent into that operation.\n */\n if (\n record.eventName === OperationType.INSERT ||\n record.eventName === OperationType.MODIFY\n ) {\n const newImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.NewImage);\n /**\n * If there is no newImage, silently continue to the next operation.\n */\n if (\n !newImage ||\n typeof newImage !== \"object\" ||\n Object.keys(newImage).length === 0\n ) {\n continue;\n }\n /**\n * Note that with the `REMOVE` event, there is no `NewImage` property. Which means,\n * if the `newImage` is `undefined`, we are dealing with a `REMOVE` event and we still\n * need to process it.\n */\n //\n else if (newImage.ignore === true) {\n // Nothing to log here, we are skipping the record intentionally.\n continue;\n }\n /**\n * Also, possibly there is no index?\n */\n //\n else if (!newImage.index) {\n console.error(\n `Could not get index from the new image, skipping event \"${record.eventID}\".`\n );\n console.log({ newImage });\n continue;\n }\n /**\n * We must decompress the data that is going into the Elasticsearch.\n */\n const data = await this.compressor.decompress(newImage.data);\n /**\n * No point in writing null or undefined data into the Elasticsearch.\n * This might happen on some error while decompressing. We will log it.\n *\n * Data should NEVER be null or undefined in the Elasticsearch DynamoDB table, unless it is a delete operations.\n * If it is - it is a bug.\n */\n if (data === undefined || data === null) {\n console.error(\n `Could not get decompressed data, skipping ES operation \"${record.eventName}\", ID ${id}. Skipping...`\n );\n continue;\n }\n\n operations.insert({\n id,\n index: newImage.index,\n data\n });\n } else if (record.eventName === OperationType.REMOVE) {\n const oldImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.OldImage);\n /**\n * If there is no index found, silently continue to the next operation.\n */\n if (!oldImage?.index) {\n continue;\n }\n operations.delete({\n id,\n index: oldImage.index\n });\n }\n }\n return operations;\n }\n}\n"],"names":["OperationsBuilder","params","operations","Operations","record","console","keys","unmarshall","id","OperationType","newImage","Object","data","oldImage"],"mappings":";;AAuBO,MAAMA;IAGT,YAAmBC,MAAgC,CAAE;QACjD,IAAI,CAAC,UAAU,GAAGA,OAAO,UAAU;IACvC;IAEA,MAAa,MAAMA,MAAqC,EAAwB;QAC5E,MAAMC,aAAa,IAAIC;QACvB,KAAK,MAAMC,UAAUH,OAAO,OAAO,CAAE;YACjC,IAAI,CAACG,OAAO,QAAQ,EAChB;YACG,IAAI,CAACA,OAAO,SAAS,EAAE;gBAC1BC,QAAQ,KAAK,CACT,CAAC,yDAAyD,EAAED,OAAO,OAAO,CAAC,EAAE,CAAC;gBAElF;YACJ;YAEA,MAAME,OAAOC,WAA+BH,OAAO,QAAQ,CAAC,IAAI;YAChE,IAAI,CAACE,MAAM,MAAM,CAACA,KAAK,EAAE,EAAE;gBACvBD,QAAQ,KAAK,CACT,CAAC,oDAAoD,EAAED,OAAO,OAAO,CAAC,EAAE,CAAC;gBAE7E;YACJ;YAEA,MAAMI,KAAK,GAAGF,KAAK,EAAE,CAAC,CAAC,EAAEA,KAAK,EAAE,EAAE;YAMlC,IACIF,OAAO,SAAS,KAAKK,cAAc,MAAM,IACzCL,OAAO,SAAS,KAAKK,cAAc,MAAM,EAC3C;gBACE,MAAMC,WAAWH,WAAgCH,OAAO,QAAQ,CAAC,QAAQ;gBAIzE,IACI,CAACM,YACD,AAAoB,YAApB,OAAOA,YACPC,AAAiC,MAAjCA,OAAO,IAAI,CAACD,UAAU,MAAM,EAE5B;gBAQC,IAAIA,AAAoB,SAApBA,SAAS,MAAM,EAEpB;gBAMC,IAAI,CAACA,SAAS,KAAK,EAAE;oBACtBL,QAAQ,KAAK,CACT,CAAC,wDAAwD,EAAED,OAAO,OAAO,CAAC,EAAE,CAAC;oBAEjFC,QAAQ,GAAG,CAAC;wBAAEK;oBAAS;oBACvB;gBACJ;gBAIA,MAAME,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAACF,SAAS,IAAI;gBAQ3D,IAAIE,QAAAA,MAAqC;oBACrCP,QAAQ,KAAK,CACT,CAAC,wDAAwD,EAAED,OAAO,SAAS,CAAC,MAAM,EAAEI,GAAG,aAAa,CAAC;oBAEzG;gBACJ;gBAEAN,WAAW,MAAM,CAAC;oBACdM;oBACA,OAAOE,SAAS,KAAK;oBACrBE;gBACJ;YACJ,OAAO,IAAIR,OAAO,SAAS,KAAKK,cAAc,MAAM,EAAE;gBAClD,MAAMI,WAAWN,WAAgCH,OAAO,QAAQ,CAAC,QAAQ;gBAIzE,IAAI,CAACS,UAAU,OACX;gBAEJX,WAAW,MAAM,CAAC;oBACdM;oBACA,OAAOK,SAAS,KAAK;gBACzB;YACJ;QACJ;QACA,OAAOX;IACX;AACJ"}
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
import { Operations } from "./Operations.js";
|
|
2
2
|
import { executeWithRetry } from "./executeWithRetry.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
}
|
|
3
|
+
class SynchronizationBuilder {
|
|
4
|
+
constructor(params){
|
|
5
|
+
this.timer = params.timer;
|
|
6
|
+
this.context = params.context;
|
|
7
|
+
this.operations = new Operations();
|
|
8
|
+
}
|
|
9
|
+
insert(params) {
|
|
10
|
+
return this.operations.insert(params);
|
|
11
|
+
}
|
|
12
|
+
modify(params) {
|
|
13
|
+
return this.operations.modify(params);
|
|
14
|
+
}
|
|
15
|
+
delete(params) {
|
|
16
|
+
return this.operations.delete(params);
|
|
17
|
+
}
|
|
18
|
+
build() {
|
|
19
|
+
return async (params)=>{
|
|
20
|
+
if (0 === this.operations.total) return;
|
|
21
|
+
await executeWithRetry({
|
|
22
|
+
...params,
|
|
23
|
+
maxRunningTime: this.timer.getRemainingMilliseconds(),
|
|
24
|
+
timer: this.timer,
|
|
25
|
+
context: this.context,
|
|
26
|
+
operations: this.operations
|
|
27
|
+
});
|
|
28
|
+
this.operations.clear();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
32
|
+
const createSynchronizationBuilder = (params)=>new SynchronizationBuilder(params);
|
|
33
|
+
export { SynchronizationBuilder, createSynchronizationBuilder };
|
|
37
34
|
|
|
38
35
|
//# sourceMappingURL=SynchronizationBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"SynchronizationBuilder.js","sources":["../src/SynchronizationBuilder.ts"],"sourcesContent":["import type {\n Context,\n IDeleteOperationParams,\n IInsertOperationParams,\n IModifyOperationParams,\n IOperations\n} from \"~/types.js\";\nimport { Operations } from \"~/Operations.js\";\nimport type { IExecuteWithRetryParams } from \"~/executeWithRetry.js\";\nimport { executeWithRetry } from \"~/executeWithRetry.js\";\nimport type { ITimer } from \"@webiny/handler-aws\";\n\nexport type ISynchronizationBuilderExecuteWithRetryParams = Omit<\n IExecuteWithRetryParams,\n \"context\" | \"timer\" | \"maxRunningTime\" | \"operations\"\n>;\n\nexport interface ISynchronizationBuilder {\n insert(params: IInsertOperationParams): void;\n delete(params: IDeleteOperationParams): void;\n build: () => (params?: ISynchronizationBuilderExecuteWithRetryParams) => Promise<void>;\n}\n\nexport interface ISynchronizationBuilderParams {\n timer: ITimer;\n context: Pick<Context, \"opensearch\">;\n}\n\nexport class SynchronizationBuilder implements ISynchronizationBuilder {\n private readonly timer: ITimer;\n private readonly context: Pick<Context, \"opensearch\">;\n private readonly operations: IOperations;\n\n public constructor(params: ISynchronizationBuilderParams) {\n this.timer = params.timer;\n this.context = params.context;\n this.operations = new Operations();\n }\n\n public insert(params: IInsertOperationParams): void {\n return this.operations.insert(params);\n }\n\n public modify(params: IModifyOperationParams): void {\n return this.operations.modify(params);\n }\n\n public delete(params: IDeleteOperationParams): void {\n return this.operations.delete(params);\n }\n\n public build() {\n return async (params?: ISynchronizationBuilderExecuteWithRetryParams) => {\n if (this.operations.total === 0) {\n return;\n }\n await executeWithRetry({\n ...params,\n maxRunningTime: this.timer.getRemainingMilliseconds(),\n timer: this.timer,\n context: this.context,\n operations: this.operations\n });\n this.operations.clear();\n };\n }\n}\n\nexport const createSynchronizationBuilder = (\n params: ISynchronizationBuilderParams\n): ISynchronizationBuilder => {\n return new SynchronizationBuilder(params);\n};\n"],"names":["SynchronizationBuilder","params","Operations","executeWithRetry","createSynchronizationBuilder"],"mappings":";;AA4BO,MAAMA;IAKT,YAAmBC,MAAqC,CAAE;QACtD,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAIC;IAC1B;IAEO,OAAOD,MAA8B,EAAQ;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA;IAClC;IAEO,OAAOA,MAA8B,EAAQ;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA;IAClC;IAEO,OAAOA,MAA8B,EAAQ;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA;IAClC;IAEO,QAAQ;QACX,OAAO,OAAOA;YACV,IAAI,AAA0B,MAA1B,IAAI,CAAC,UAAU,CAAC,KAAK,EACrB;YAEJ,MAAME,iBAAiB;gBACnB,GAAGF,MAAM;gBACT,gBAAgB,IAAI,CAAC,KAAK,CAAC,wBAAwB;gBACnD,OAAO,IAAI,CAAC,KAAK;gBACjB,SAAS,IAAI,CAAC,OAAO;gBACrB,YAAY,IAAI,CAAC,UAAU;YAC/B;YACA,IAAI,CAAC,UAAU,CAAC,KAAK;QACzB;IACJ;AACJ;AAEO,MAAMG,+BAA+B,CACxCH,SAEO,IAAID,uBAAuBC"}
|
package/eventHandler.js
CHANGED
|
@@ -2,49 +2,30 @@ import { createDynamoDBEventHandler, timerFactory } from "@webiny/handler-aws";
|
|
|
2
2
|
import { OperationsBuilder } from "./OperationsBuilder.js";
|
|
3
3
|
import { executeWithRetry } from "./executeWithRetry.js";
|
|
4
4
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Also, we need to set the maximum running time for the Lambda Function.
|
|
8
|
-
* https://github.com/webiny/webiny-js/blob/f7352d418da2b5ae0b781376be46785aa7ac6ae0/packages/pulumi-aws/src/apps/core/CoreOpenSearch.ts#L232
|
|
9
|
-
* https://github.com/webiny/webiny-js/blob/f7352d418da2b5ae0b781376be46785aa7ac6ae0/packages/pulumi-aws/src/apps/core/CoreElasticSearch.ts#L218
|
|
10
|
-
*/
|
|
11
5
|
const MAX_RUNNING_TIME = 900;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (operations.total === 0) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execute the operations with retry.
|
|
39
|
-
*/
|
|
40
|
-
await executeWithRetry({
|
|
41
|
-
timer,
|
|
42
|
-
maxRunningTime: MAX_RUNNING_TIME,
|
|
43
|
-
context,
|
|
44
|
-
operations
|
|
6
|
+
const createEventHandler = ()=>createDynamoDBEventHandler(async ({ event, context: ctx, lambdaContext })=>{
|
|
7
|
+
const timer = timerFactory(lambdaContext);
|
|
8
|
+
const context = ctx;
|
|
9
|
+
if (!context.opensearch) {
|
|
10
|
+
console.error("Missing opensearch definition on context.");
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const compressor = context.container.resolve(CompressionHandler);
|
|
14
|
+
const builder = new OperationsBuilder({
|
|
15
|
+
compressor
|
|
16
|
+
});
|
|
17
|
+
const operations = await builder.build({
|
|
18
|
+
records: event.Records
|
|
19
|
+
});
|
|
20
|
+
if (0 === operations.total) return null;
|
|
21
|
+
await executeWithRetry({
|
|
22
|
+
timer,
|
|
23
|
+
maxRunningTime: MAX_RUNNING_TIME,
|
|
24
|
+
context,
|
|
25
|
+
operations
|
|
26
|
+
});
|
|
27
|
+
return null;
|
|
45
28
|
});
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
};
|
|
29
|
+
export { createEventHandler };
|
|
49
30
|
|
|
50
31
|
//# sourceMappingURL=eventHandler.js.map
|
package/eventHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"eventHandler.js","sources":["../src/eventHandler.ts"],"sourcesContent":["import { createDynamoDBEventHandler, timerFactory } from \"@webiny/handler-aws\";\nimport type { Context } from \"~/types.js\";\nimport { OperationsBuilder } from \"~/OperationsBuilder.js\";\nimport { executeWithRetry } from \"~/executeWithRetry.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\n\n/**\n * Also, we need to set the maximum running time for the Lambda Function.\n * https://github.com/webiny/webiny-js/blob/f7352d418da2b5ae0b781376be46785aa7ac6ae0/packages/pulumi-aws/src/apps/core/CoreOpenSearch.ts#L232\n * https://github.com/webiny/webiny-js/blob/f7352d418da2b5ae0b781376be46785aa7ac6ae0/packages/pulumi-aws/src/apps/core/CoreElasticSearch.ts#L218\n */\nconst MAX_RUNNING_TIME = 900;\n\nexport const createEventHandler = () => {\n return createDynamoDBEventHandler(async ({ event, context: ctx, lambdaContext }) => {\n const timer = timerFactory(lambdaContext);\n const context = ctx as unknown as Context;\n if (!context.opensearch) {\n console.error(\"Missing opensearch definition on context.\");\n return null;\n }\n\n const compressor = context.container.resolve(CompressionHandler);\n\n const builder = new OperationsBuilder({\n compressor\n });\n\n const operations = await builder.build({\n records: event.Records\n });\n /**\n * No need to do anything if there are no operations.\n */\n if (operations.total === 0) {\n return null;\n }\n /**\n * Execute the operations with retry.\n */\n await executeWithRetry({\n timer,\n maxRunningTime: MAX_RUNNING_TIME,\n context,\n operations\n });\n\n return null;\n });\n};\n"],"names":["MAX_RUNNING_TIME","createEventHandler","createDynamoDBEventHandler","event","ctx","lambdaContext","timer","timerFactory","context","console","compressor","CompressionHandler","builder","OperationsBuilder","operations","executeWithRetry"],"mappings":";;;;AAWA,MAAMA,mBAAmB;AAElB,MAAMC,qBAAqB,IACvBC,2BAA2B,OAAO,EAAEC,KAAK,EAAE,SAASC,GAAG,EAAEC,aAAa,EAAE;QAC3E,MAAMC,QAAQC,aAAaF;QAC3B,MAAMG,UAAUJ;QAChB,IAAI,CAACI,QAAQ,UAAU,EAAE;YACrBC,QAAQ,KAAK,CAAC;YACd,OAAO;QACX;QAEA,MAAMC,aAAaF,QAAQ,SAAS,CAAC,OAAO,CAACG;QAE7C,MAAMC,UAAU,IAAIC,kBAAkB;YAClCH;QACJ;QAEA,MAAMI,aAAa,MAAMF,QAAQ,KAAK,CAAC;YACnC,SAAST,MAAM,OAAO;QAC1B;QAIA,IAAIW,AAAqB,MAArBA,WAAW,KAAK,EAChB,OAAO;QAKX,MAAMC,iBAAiB;YACnBT;YACA,gBAAgBN;YAChBQ;YACAM;QACJ;QAEA,OAAO;IACX"}
|
package/execute.js
CHANGED
|
@@ -1,137 +1,98 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenSearchCatClusterHealthStatus, UnhealthyClusterError, WaitingHealthyClusterAbortedError, createWaitUntilHealthy } from "@webiny/api-opensearch";
|
|
2
2
|
import { WebinyError } from "@webiny/error";
|
|
3
3
|
import { shouldShowLogs } from "./helpers/shouldShowLogs.js";
|
|
4
|
-
const getError = item
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (reason.match(/no such index \[([a-zA-Z0-9_-]+)\]/) !== null) {
|
|
10
|
-
return "index";
|
|
11
|
-
}
|
|
12
|
-
return reason;
|
|
4
|
+
const getError = (item)=>{
|
|
5
|
+
if (!item.index?.error?.reason) return null;
|
|
6
|
+
const reason = item.index.error.reason;
|
|
7
|
+
if (null !== reason.match(/no such index \[([a-zA-Z0-9_-]+)\]/)) return "index";
|
|
8
|
+
return reason;
|
|
13
9
|
};
|
|
14
|
-
const checkErrors = result
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
console.error("Body item with error", item);
|
|
29
|
-
throw new WebinyError(err, "DYNAMODB_TO_OPENSEARCH_ERROR", item);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export const execute = params => {
|
|
33
|
-
return async () => {
|
|
34
|
-
const {
|
|
35
|
-
context,
|
|
36
|
-
timer,
|
|
37
|
-
maxRunningTime,
|
|
38
|
-
maxProcessorPercent,
|
|
39
|
-
operations
|
|
40
|
-
} = params;
|
|
41
|
-
if (operations.total === 0) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const remainingTime = timer.getRemainingSeconds();
|
|
45
|
-
const runningTime = maxRunningTime - remainingTime;
|
|
46
|
-
const maxWaitingTime = remainingTime - 90;
|
|
47
|
-
if (shouldShowLogs()) {
|
|
48
|
-
console.debug(`The Lambda is already running for ${runningTime}s. Setting Health Check max waiting time: ${maxWaitingTime}s`);
|
|
49
|
-
}
|
|
50
|
-
const healthCheck = createWaitUntilHealthy(context.opensearch, {
|
|
51
|
-
minClusterHealthStatus: OpenSearchCatClusterHealthStatus.Yellow,
|
|
52
|
-
waitingTimeStep: 30,
|
|
53
|
-
maxProcessorPercent,
|
|
54
|
-
maxWaitingTime
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// const log = context.logger.withSource("dynamodbToElasticsearch");
|
|
58
|
-
const log = {
|
|
59
|
-
notice: (...params) => {
|
|
60
|
-
console.log(...params);
|
|
61
|
-
},
|
|
62
|
-
debug: (...params) => {
|
|
63
|
-
console.debug(...params);
|
|
64
|
-
},
|
|
65
|
-
info: (...params) => {
|
|
66
|
-
console.info(...params);
|
|
67
|
-
},
|
|
68
|
-
warn: (...params) => {
|
|
69
|
-
console.warn(...params);
|
|
70
|
-
},
|
|
71
|
-
error: (...params) => {
|
|
72
|
-
console.error(...params);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
try {
|
|
76
|
-
await healthCheck.wait({
|
|
77
|
-
async onUnhealthy({
|
|
78
|
-
startedAt,
|
|
79
|
-
runs,
|
|
80
|
-
mustEndAt,
|
|
81
|
-
waitingTimeStep,
|
|
82
|
-
waitingReason
|
|
83
|
-
}) {
|
|
84
|
-
console.debug(`Cluster is unhealthy on run #${runs}.`, {
|
|
85
|
-
startedAt,
|
|
86
|
-
mustEndAt,
|
|
87
|
-
waitingTimeStep,
|
|
88
|
-
waitingReason
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
async onTimeout({
|
|
92
|
-
startedAt,
|
|
93
|
-
runs,
|
|
94
|
-
waitingTimeStep,
|
|
95
|
-
mustEndAt,
|
|
96
|
-
waitingReason
|
|
97
|
-
}) {
|
|
98
|
-
console.error(`Cluster health check timeout on run #${runs}.`, {
|
|
99
|
-
startedAt,
|
|
100
|
-
mustEndAt,
|
|
101
|
-
waitingTimeStep,
|
|
102
|
-
waitingReason
|
|
103
|
-
});
|
|
10
|
+
const checkErrors = (result)=>{
|
|
11
|
+
if (!result || !result.body || !result.body.items) return;
|
|
12
|
+
for (const item of result.body.items){
|
|
13
|
+
const err = getError(item);
|
|
14
|
+
if (err) {
|
|
15
|
+
if ("index" === err) {
|
|
16
|
+
if ("true" === process.env.DEBUG) console.error("Bulk response", JSON.stringify(result, null, 2));
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
console.error("Body item with error", item);
|
|
20
|
+
throw new WebinyError(err, "DYNAMODB_TO_OPENSEARCH_ERROR", item);
|
|
104
21
|
}
|
|
105
|
-
});
|
|
106
|
-
} catch (ex) {
|
|
107
|
-
if (ex instanceof UnhealthyClusterError || ex instanceof WaitingHealthyClusterAbortedError) {
|
|
108
|
-
throw ex;
|
|
109
|
-
}
|
|
110
|
-
console.error(`Cluster health check failed.`, ex);
|
|
111
|
-
throw ex;
|
|
112
22
|
}
|
|
113
|
-
try {
|
|
114
|
-
const res = await context.opensearch.bulk({
|
|
115
|
-
body: operations.items
|
|
116
|
-
});
|
|
117
|
-
checkErrors(res);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
log.error(error, {
|
|
120
|
-
tenant: "root"
|
|
121
|
-
});
|
|
122
|
-
if (shouldShowLogs() === false) {
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
const meta = error?.meta || {};
|
|
126
|
-
delete meta["meta"];
|
|
127
|
-
console.error("Bulk error", JSON.stringify(error, null, 2));
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
130
|
-
if (shouldShowLogs() === false) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
console.info(`Transferred ${operations.total} record operations to Elasticsearch.`);
|
|
134
|
-
};
|
|
135
23
|
};
|
|
24
|
+
const execute = (params)=>async ()=>{
|
|
25
|
+
const { context, timer, maxRunningTime, maxProcessorPercent, operations } = params;
|
|
26
|
+
if (0 === operations.total) return;
|
|
27
|
+
const remainingTime = timer.getRemainingSeconds();
|
|
28
|
+
const runningTime = maxRunningTime - remainingTime;
|
|
29
|
+
const maxWaitingTime = remainingTime - 90;
|
|
30
|
+
if (shouldShowLogs()) console.debug(`The Lambda is already running for ${runningTime}s. Setting Health Check max waiting time: ${maxWaitingTime}s`);
|
|
31
|
+
const healthCheck = createWaitUntilHealthy(context.opensearch, {
|
|
32
|
+
minClusterHealthStatus: OpenSearchCatClusterHealthStatus.Yellow,
|
|
33
|
+
waitingTimeStep: 30,
|
|
34
|
+
maxProcessorPercent,
|
|
35
|
+
maxWaitingTime
|
|
36
|
+
});
|
|
37
|
+
const log = {
|
|
38
|
+
notice: (...params)=>{
|
|
39
|
+
console.log(...params);
|
|
40
|
+
},
|
|
41
|
+
debug: (...params)=>{
|
|
42
|
+
console.debug(...params);
|
|
43
|
+
},
|
|
44
|
+
info: (...params)=>{
|
|
45
|
+
console.info(...params);
|
|
46
|
+
},
|
|
47
|
+
warn: (...params)=>{
|
|
48
|
+
console.warn(...params);
|
|
49
|
+
},
|
|
50
|
+
error: (...params)=>{
|
|
51
|
+
console.error(...params);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
await healthCheck.wait({
|
|
56
|
+
async onUnhealthy ({ startedAt, runs, mustEndAt, waitingTimeStep, waitingReason }) {
|
|
57
|
+
console.debug(`Cluster is unhealthy on run #${runs}.`, {
|
|
58
|
+
startedAt,
|
|
59
|
+
mustEndAt,
|
|
60
|
+
waitingTimeStep,
|
|
61
|
+
waitingReason
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
async onTimeout ({ startedAt, runs, waitingTimeStep, mustEndAt, waitingReason }) {
|
|
65
|
+
console.error(`Cluster health check timeout on run #${runs}.`, {
|
|
66
|
+
startedAt,
|
|
67
|
+
mustEndAt,
|
|
68
|
+
waitingTimeStep,
|
|
69
|
+
waitingReason
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
if (ex instanceof UnhealthyClusterError || ex instanceof WaitingHealthyClusterAbortedError) throw ex;
|
|
75
|
+
console.error("Cluster health check failed.", ex);
|
|
76
|
+
throw ex;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const res = await context.opensearch.bulk({
|
|
80
|
+
body: operations.items
|
|
81
|
+
});
|
|
82
|
+
checkErrors(res);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
log.error(error, {
|
|
85
|
+
tenant: "root"
|
|
86
|
+
});
|
|
87
|
+
if (false === shouldShowLogs()) throw error;
|
|
88
|
+
const meta = error?.meta || {};
|
|
89
|
+
delete meta["meta"];
|
|
90
|
+
console.error("Bulk error", JSON.stringify(error, null, 2));
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
if (false === shouldShowLogs()) return;
|
|
94
|
+
console.info(`Transferred ${operations.total} record operations to Elasticsearch.`);
|
|
95
|
+
};
|
|
96
|
+
export { execute };
|
|
136
97
|
|
|
137
98
|
//# sourceMappingURL=execute.js.map
|
package/execute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"execute.js","sources":["../src/execute.ts"],"sourcesContent":["import {\n createWaitUntilHealthy,\n OpenSearchCatClusterHealthStatus,\n UnhealthyClusterError,\n WaitingHealthyClusterAbortedError\n} from \"@webiny/api-opensearch\";\nimport type { ITimer } from \"@webiny/handler-aws\";\nimport type { ApiResponse } from \"@webiny/api-opensearch/types.js\";\n\nimport { WebinyError } from \"@webiny/error\";\nimport type { Context, IOperations } from \"./types.js\";\nimport { shouldShowLogs } from \"~/helpers/shouldShowLogs.js\";\n\nexport interface BulkOperationsResponseBodyItemIndexError {\n reason?: string;\n}\n\nexport interface BulkOperationsResponseBodyItemIndex {\n error?: BulkOperationsResponseBodyItemIndexError;\n}\n\nexport interface BulkOperationsResponseBodyItem {\n index?: BulkOperationsResponseBodyItemIndex;\n error?: string;\n}\n\nexport interface BulkOperationsResponseBody {\n items: BulkOperationsResponseBodyItem[];\n}\n\nexport interface IExecuteParams {\n timer: ITimer;\n maxRunningTime: number;\n maxProcessorPercent: number;\n context: Pick<Context, \"opensearch\">;\n operations: Pick<IOperations, \"items\" | \"total\">;\n}\n\nconst getError = (item: BulkOperationsResponseBodyItem): string | null => {\n if (!item.index?.error?.reason) {\n return null;\n }\n const reason = item.index.error.reason;\n if (reason.match(/no such index \\[([a-zA-Z0-9_-]+)\\]/) !== null) {\n return \"index\";\n }\n return reason;\n};\n\nconst checkErrors = (result?: ApiResponse): void => {\n if (!result || !result.body || !result.body.items) {\n return;\n }\n for (const item of result.body.items) {\n const err = getError(item);\n if (!err) {\n continue;\n } else if (err === \"index\") {\n if (process.env.DEBUG === \"true\") {\n console.error(\"Bulk response\", JSON.stringify(result, null, 2));\n }\n continue;\n }\n console.error(\"Body item with error\", item);\n throw new WebinyError(err, \"DYNAMODB_TO_OPENSEARCH_ERROR\", item);\n }\n};\n\nexport const execute = (params: IExecuteParams) => {\n return async (): Promise<void> => {\n const { context, timer, maxRunningTime, maxProcessorPercent, operations } = params;\n\n if (operations.total === 0) {\n return;\n }\n\n const remainingTime = timer.getRemainingSeconds();\n const runningTime = maxRunningTime - remainingTime;\n const maxWaitingTime = remainingTime - 90;\n\n if (shouldShowLogs()) {\n console.debug(\n `The Lambda is already running for ${runningTime}s. Setting Health Check max waiting time: ${maxWaitingTime}s`\n );\n }\n\n const healthCheck = createWaitUntilHealthy(context.opensearch, {\n minClusterHealthStatus: OpenSearchCatClusterHealthStatus.Yellow,\n waitingTimeStep: 30,\n maxProcessorPercent,\n maxWaitingTime\n });\n\n // const log = context.logger.withSource(\"dynamodbToElasticsearch\");\n const log = {\n notice: (...params: any[]) => {\n console.log(...params);\n },\n debug: (...params: any[]) => {\n console.debug(...params);\n },\n info: (...params: any[]) => {\n console.info(...params);\n },\n warn: (...params: any[]) => {\n console.warn(...params);\n },\n error: (...params: any[]) => {\n console.error(...params);\n }\n };\n\n try {\n await healthCheck.wait({\n async onUnhealthy({ startedAt, runs, mustEndAt, waitingTimeStep, waitingReason }) {\n console.debug(`Cluster is unhealthy on run #${runs}.`, {\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason\n });\n },\n async onTimeout({ startedAt, runs, waitingTimeStep, mustEndAt, waitingReason }) {\n console.error(`Cluster health check timeout on run #${runs}.`, {\n startedAt,\n mustEndAt,\n waitingTimeStep,\n waitingReason\n });\n }\n });\n } catch (ex) {\n if (\n ex instanceof UnhealthyClusterError ||\n ex instanceof WaitingHealthyClusterAbortedError\n ) {\n throw ex;\n }\n console.error(`Cluster health check failed.`, ex);\n throw ex;\n }\n\n try {\n const res = await context.opensearch.bulk({\n body: operations.items\n });\n checkErrors(res);\n } catch (error) {\n log.error(error, {\n tenant: \"root\"\n });\n\n if (shouldShowLogs() === false) {\n throw error;\n }\n const meta = error?.meta || {};\n delete meta[\"meta\"];\n console.error(\"Bulk error\", JSON.stringify(error, null, 2));\n throw error;\n }\n if (shouldShowLogs() === false) {\n return;\n }\n console.info(`Transferred ${operations.total} record operations to Elasticsearch.`);\n };\n};\n"],"names":["getError","item","reason","checkErrors","result","err","process","console","JSON","WebinyError","execute","params","context","timer","maxRunningTime","maxProcessorPercent","operations","remainingTime","runningTime","maxWaitingTime","shouldShowLogs","healthCheck","createWaitUntilHealthy","OpenSearchCatClusterHealthStatus","log","startedAt","runs","mustEndAt","waitingTimeStep","waitingReason","ex","UnhealthyClusterError","WaitingHealthyClusterAbortedError","res","error","meta"],"mappings":"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"}
|
package/executeWithRetry.js
CHANGED
|
@@ -1,47 +1,37 @@
|
|
|
1
1
|
import { execute } from "./execute.js";
|
|
2
2
|
import { NotEnoughRemainingTimeError } from "./NotEnoughRemainingTimeError.js";
|
|
3
|
-
import
|
|
3
|
+
import p_retry from "p-retry";
|
|
4
4
|
import { getNumberEnvVariable } from "./helpers/getNumberEnvVariable.js";
|
|
5
5
|
const minRemainingSecondsToTimeout = 120;
|
|
6
|
-
const MAX_PROCESSOR_PERCENT = getNumberEnvVariable("MAX_ES_PROCESSOR", process.env.NODE_ENV
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (attemptNumber < retries * 0.75) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
console.error(`Attempt #${attemptNumber} failed.`);
|
|
38
|
-
console.error(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
} catch (ex) {
|
|
42
|
-
// TODO implement storing of failed operations
|
|
43
|
-
throw ex;
|
|
44
|
-
}
|
|
6
|
+
const MAX_PROCESSOR_PERCENT = getNumberEnvVariable("MAX_ES_PROCESSOR", "test" === process.env.NODE_ENV ? 101 : 98);
|
|
7
|
+
const executeWithRetry = async (params)=>{
|
|
8
|
+
const maxRetryTime = getNumberEnvVariable("WEBINY_DYNAMODB_TO_OPENSEARCH_MAX_RETRY_TIME", params.maxRetryTime || 300000);
|
|
9
|
+
const retries = getNumberEnvVariable("WEBINY_DYNAMODB_TO_OPENSEARCH_RETRIES", params.retries || 20);
|
|
10
|
+
const minTimeout = getNumberEnvVariable("WEBINY_DYNAMODB_TO_OPENSEARCH_MIN_TIMEOUT", params.minTimeout || 1500);
|
|
11
|
+
const maxTimeout = getNumberEnvVariable("WEBINY_DYNAMODB_TO_OPENSEARCH_MAX_TIMEOUT", params.maxTimeout || 30000);
|
|
12
|
+
try {
|
|
13
|
+
await p_retry(execute({
|
|
14
|
+
timer: params.timer,
|
|
15
|
+
maxRunningTime: params.maxRunningTime,
|
|
16
|
+
maxProcessorPercent: params.maxProcessorPercent || MAX_PROCESSOR_PERCENT,
|
|
17
|
+
context: params.context,
|
|
18
|
+
operations: params.operations
|
|
19
|
+
}), {
|
|
20
|
+
maxRetryTime,
|
|
21
|
+
retries,
|
|
22
|
+
minTimeout,
|
|
23
|
+
maxTimeout,
|
|
24
|
+
onFailedAttempt: ({ error, attemptNumber })=>{
|
|
25
|
+
if (params.timer.getRemainingSeconds() < minRemainingSecondsToTimeout) throw new NotEnoughRemainingTimeError(error);
|
|
26
|
+
if (attemptNumber < 0.75 * retries) return;
|
|
27
|
+
console.error(`Attempt #${attemptNumber} failed.`);
|
|
28
|
+
console.error(error);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
} catch (ex) {
|
|
32
|
+
throw ex;
|
|
33
|
+
}
|
|
45
34
|
};
|
|
35
|
+
export { executeWithRetry };
|
|
46
36
|
|
|
47
37
|
//# sourceMappingURL=executeWithRetry.js.map
|
package/executeWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"executeWithRetry.js","sources":["../src/executeWithRetry.ts"],"sourcesContent":["import type { IExecuteParams } from \"~/execute.js\";\nimport { execute } from \"~/execute.js\";\nimport { NotEnoughRemainingTimeError } from \"~/NotEnoughRemainingTimeError.js\";\nimport pRetry from \"p-retry\";\nimport { getNumberEnvVariable } from \"./helpers/getNumberEnvVariable.js\";\n\nconst minRemainingSecondsToTimeout = 120;\n\nconst MAX_PROCESSOR_PERCENT = getNumberEnvVariable(\n \"MAX_ES_PROCESSOR\",\n process.env.NODE_ENV === \"test\" ? 101 : 98\n);\n\nexport interface IExecuteWithRetryParams extends Omit<IExecuteParams, \"maxProcessorPercent\"> {\n maxRetryTime?: number;\n retries?: number;\n minTimeout?: number;\n maxTimeout?: number;\n maxProcessorPercent?: number;\n}\n\nexport const executeWithRetry = async (params: IExecuteWithRetryParams) => {\n const maxRetryTime = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_OPENSEARCH_MAX_RETRY_TIME\",\n params.maxRetryTime || 300000\n );\n const retries = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_OPENSEARCH_RETRIES\",\n params.retries || 20\n );\n const minTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_OPENSEARCH_MIN_TIMEOUT\",\n params.minTimeout || 1500\n );\n const maxTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_OPENSEARCH_MAX_TIMEOUT\",\n params.maxTimeout || 30000\n );\n\n try {\n await pRetry(\n execute({\n timer: params.timer,\n maxRunningTime: params.maxRunningTime,\n maxProcessorPercent: params.maxProcessorPercent || MAX_PROCESSOR_PERCENT,\n context: params.context,\n operations: params.operations\n }),\n {\n maxRetryTime,\n retries,\n minTimeout,\n maxTimeout,\n onFailedAttempt: ({ error, attemptNumber }) => {\n if (params.timer.getRemainingSeconds() < minRemainingSecondsToTimeout) {\n throw new NotEnoughRemainingTimeError(error);\n }\n /**\n * We will only log attempts which are after 3/4 of total attempts.\n */\n if (attemptNumber < retries * 0.75) {\n return;\n }\n console.error(`Attempt #${attemptNumber} failed.`);\n console.error(error);\n }\n }\n );\n } catch (ex) {\n // TODO implement storing of failed operations\n throw ex;\n }\n};\n"],"names":["minRemainingSecondsToTimeout","MAX_PROCESSOR_PERCENT","getNumberEnvVariable","process","executeWithRetry","params","maxRetryTime","retries","minTimeout","maxTimeout","pRetry","execute","error","attemptNumber","NotEnoughRemainingTimeError","console","ex"],"mappings":";;;;AAMA,MAAMA,+BAA+B;AAErC,MAAMC,wBAAwBC,qBAC1B,oBACAC,AAAyB,WAAzBA,QAAQ,GAAG,CAAC,QAAQ,GAAc,MAAM;AAWrC,MAAMC,mBAAmB,OAAOC;IACnC,MAAMC,eAAeJ,qBACjB,gDACAG,OAAO,YAAY,IAAI;IAE3B,MAAME,UAAUL,qBACZ,yCACAG,OAAO,OAAO,IAAI;IAEtB,MAAMG,aAAaN,qBACf,6CACAG,OAAO,UAAU,IAAI;IAEzB,MAAMI,aAAaP,qBACf,6CACAG,OAAO,UAAU,IAAI;IAGzB,IAAI;QACA,MAAMK,QACFC,QAAQ;YACJ,OAAON,OAAO,KAAK;YACnB,gBAAgBA,OAAO,cAAc;YACrC,qBAAqBA,OAAO,mBAAmB,IAAIJ;YACnD,SAASI,OAAO,OAAO;YACvB,YAAYA,OAAO,UAAU;QACjC,IACA;YACIC;YACAC;YACAC;YACAC;YACA,iBAAiB,CAAC,EAAEG,KAAK,EAAEC,aAAa,EAAE;gBACtC,IAAIR,OAAO,KAAK,CAAC,mBAAmB,KAAKL,8BACrC,MAAM,IAAIc,4BAA4BF;gBAK1C,IAAIC,gBAAgBN,AAAU,OAAVA,SAChB;gBAEJQ,QAAQ,KAAK,CAAC,CAAC,SAAS,EAAEF,cAAc,QAAQ,CAAC;gBACjDE,QAAQ,KAAK,CAACH;YAClB;QACJ;IAER,EAAE,OAAOI,IAAI;QAET,MAAMA;IACV;AACJ"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return def;
|
|
6
|
-
|
|
7
|
-
return def;
|
|
8
|
-
}
|
|
9
|
-
return value;
|
|
1
|
+
const getNumberEnvVariable = (name, def)=>{
|
|
2
|
+
const input = process.env[name];
|
|
3
|
+
const value = Number(input);
|
|
4
|
+
if (isNaN(value)) return def;
|
|
5
|
+
if (value <= 0) return def;
|
|
6
|
+
return value;
|
|
10
7
|
};
|
|
8
|
+
export { getNumberEnvVariable };
|
|
11
9
|
|
|
12
10
|
//# sourceMappingURL=getNumberEnvVariable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"helpers/getNumberEnvVariable.js","sources":["../../src/helpers/getNumberEnvVariable.ts"],"sourcesContent":["export const getNumberEnvVariable = (name: string, def: number): number => {\n const input = process.env[name];\n const value = Number(input);\n if (isNaN(value)) {\n return def;\n } else if (value <= 0) {\n return def;\n }\n return value;\n};\n"],"names":["getNumberEnvVariable","name","def","input","process","value","Number","isNaN"],"mappings":"AAAO,MAAMA,uBAAuB,CAACC,MAAcC;IAC/C,MAAMC,QAAQC,QAAQ,GAAG,CAACH,KAAK;IAC/B,MAAMI,QAAQC,OAAOH;IACrB,IAAII,MAAMF,QACN,OAAOH;IACJ,IAAIG,SAAS,GAChB,OAAOH;IAEX,OAAOG;AACX"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
if (process.env.TESTING === "true") {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
return process.env.DEBUG === "true";
|
|
1
|
+
const shouldShowLogs = ()=>{
|
|
2
|
+
if ("true" === process.env.TESTING) return false;
|
|
3
|
+
return "true" === process.env.DEBUG;
|
|
9
4
|
};
|
|
5
|
+
export { shouldShowLogs };
|
|
10
6
|
|
|
11
7
|
//# sourceMappingURL=shouldShowLogs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"helpers/shouldShowLogs.js","sources":["../../src/helpers/shouldShowLogs.ts"],"sourcesContent":["export const shouldShowLogs = (): boolean => {\n /**\n * Don't show logs during tests, really no point.\n */\n if (process.env.TESTING === \"true\") {\n return false;\n }\n return process.env.DEBUG === \"true\";\n};\n"],"names":["shouldShowLogs","process"],"mappings":"AAAO,MAAMA,iBAAiB;IAI1B,IAAIC,AAAwB,WAAxBA,QAAQ,GAAG,CAAC,OAAO,EACnB,OAAO;IAEX,OAAOA,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK;AAC5B"}
|
package/index.js
CHANGED
package/marshall.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { marshall
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return value;
|
|
5
|
-
}
|
|
6
|
-
return baseMarshall(value);
|
|
1
|
+
import { marshall, unmarshall } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
const marshall_marshall = (value)=>{
|
|
3
|
+
if (!value) return value;
|
|
4
|
+
return marshall(value);
|
|
7
5
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* We can safely cast the return value to `T` because we are 100% positive that this is correct.
|
|
14
|
-
*/
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
return baseUnmarshall(value);
|
|
6
|
+
const marshall_unmarshall = (value)=>{
|
|
7
|
+
if (!value) return;
|
|
8
|
+
return unmarshall(value);
|
|
17
9
|
};
|
|
10
|
+
export { marshall_marshall as marshall, marshall_unmarshall as unmarshall };
|
|
18
11
|
|
|
19
12
|
//# sourceMappingURL=marshall.js.map
|
package/marshall.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"marshall.js","sources":["../src/marshall.ts"],"sourcesContent":["import {\n marshall as baseMarshall,\n unmarshall as baseUnmarshall\n} from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nimport type { AttributeValue } from \"@webiny/handler-aws/types.js\";\n\nexport interface MarshalledValue {\n [key: string]: AttributeValue;\n}\n\nexport const marshall = (value: GenericRecord): MarshalledValue => {\n if (!value) {\n return value;\n }\n return baseMarshall(value) as MarshalledValue;\n};\n\nexport const unmarshall = <T>(value?: MarshalledValue): T | undefined => {\n if (!value) {\n return undefined;\n }\n /**\n * We can safely cast the return value to `T` because we are 100% positive that this is correct.\n */\n // @ts-expect-error\n return baseUnmarshall(value) as T;\n};\n"],"names":["marshall","value","baseMarshall","unmarshall","baseUnmarshall"],"mappings":";AAYO,MAAMA,oBAAW,CAACC;IACrB,IAAI,CAACA,OACD,OAAOA;IAEX,OAAOC,SAAaD;AACxB;AAEO,MAAME,sBAAa,CAAIF;IAC1B,IAAI,CAACA,OACD;IAMJ,OAAOG,WAAeH;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-dynamodb-to-elasticsearch",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "Webiny Ltd.",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@webiny/api": "6.
|
|
19
|
-
"@webiny/api-opensearch": "6.
|
|
20
|
-
"@webiny/aws-sdk": "6.
|
|
21
|
-
"@webiny/error": "6.
|
|
22
|
-
"@webiny/handler-aws": "6.
|
|
23
|
-
"@webiny/utils": "6.
|
|
18
|
+
"@webiny/api": "6.4.0-beta.1",
|
|
19
|
+
"@webiny/api-opensearch": "6.4.0-beta.1",
|
|
20
|
+
"@webiny/aws-sdk": "6.4.0-beta.1",
|
|
21
|
+
"@webiny/error": "6.4.0-beta.1",
|
|
22
|
+
"@webiny/handler-aws": "6.4.0-beta.1",
|
|
23
|
+
"@webiny/utils": "6.4.0-beta.1",
|
|
24
24
|
"p-retry": "8.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@webiny/build-tools": "6.
|
|
28
|
-
"@webiny/plugins": "6.
|
|
27
|
+
"@webiny/build-tools": "6.4.0-beta.1",
|
|
28
|
+
"@webiny/plugins": "6.4.0-beta.1",
|
|
29
29
|
"typescript": "6.0.3"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"__tests__"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
|
|
41
41
|
}
|
package/types.js
CHANGED
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./eventHandler.js\";\nexport * from \"./execute.js\";\nexport * from \"./executeWithRetry.js\";\nexport * from \"./marshall.js\";\nexport * from \"./NotEnoughRemainingTimeError.js\";\nexport * from \"./Operations.js\";\nexport * from \"./OperationsBuilder.js\";\nexport * from \"./SynchronizationBuilder.js\";\nexport type * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { DynamoDBRecord, Context as HandlerContext } from \"@webiny/handler-aws/types.js\";\nimport type { OpenSearchContext } from \"@webiny/api-opensearch/types.js\";\n\nexport interface IOperationsBuilderBuildParams {\n records: DynamoDBRecord[];\n}\n\nexport interface IOperationsBuilder {\n build(params: IOperationsBuilderBuildParams): Promise<IOperations>;\n}\n\nexport interface IInsertOperationParams {\n id: string;\n index: string;\n data: GenericRecord;\n}\n\nexport type IModifyOperationParams = IInsertOperationParams;\n\nexport interface IDeleteOperationParams {\n id: string;\n index: string;\n}\n\nexport interface IOperations {\n items: GenericRecord[];\n total: number;\n clear(): void;\n insert(params: IInsertOperationParams): void;\n modify(params: IModifyOperationParams): void;\n delete(params: IDeleteOperationParams): void;\n}\n\nexport interface Context extends OpenSearchContext, HandlerContext {}\n"],"mappings":"","ignoreList":[]}
|