@forzalabs/remora 1.0.14 → 1.0.16
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.
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const mongodb_1 = require("mongodb");
|
|
16
16
|
const Helper_1 = __importDefault(require("../helper/Helper"));
|
|
17
17
|
const Settings_1 = __importDefault(require("../helper/Settings"));
|
|
18
|
-
const Affirm_1 = __importDefault(require("../core/Affirm"));
|
|
19
18
|
class DatabaseEngineClass {
|
|
20
19
|
constructor() {
|
|
21
20
|
this.MAX_TRY_CONNECTION = 3;
|
|
@@ -23,15 +22,16 @@ class DatabaseEngineClass {
|
|
|
23
22
|
this.connect = () => __awaiter(this, void 0, void 0, function* () {
|
|
24
23
|
// WARNING: this was changed during the deployment to ECS...
|
|
25
24
|
// I've reverted it, but maybe it needs to be changed or looked into...
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
var _a;
|
|
26
|
+
this._uri = ((_a = process.env.MONGO_URI) !== null && _a !== void 0 ? _a : Helper_1.default.isDev())
|
|
27
|
+
? 'mongodb://mongo:27017/remora'
|
|
28
|
+
: 'mongodb://localhost:27017/remora';
|
|
29
|
+
this._client = new mongodb_1.MongoClient(this._uri);
|
|
30
30
|
const errors = [];
|
|
31
31
|
this._client = new mongodb_1.MongoClient(this._uri);
|
|
32
32
|
for (let i = 0; i < this.MAX_TRY_CONNECTION; i++) {
|
|
33
33
|
try {
|
|
34
|
-
console.log(`Attempting to connect to mongo`);
|
|
34
|
+
console.log(`Attempting to connect to mongo "${this._uri}`);
|
|
35
35
|
yield this._client.connect();
|
|
36
36
|
this._db = this._client.db(Settings_1.default.db.name);
|
|
37
37
|
this._connected = true;
|
package/engines/Environment.js
CHANGED
|
@@ -45,7 +45,7 @@ class EnvironmentClass {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
catch (error) {
|
|
48
|
-
throw new Error(`Error loading configuration from ${configPath}: ${error.message}`);
|
|
48
|
+
throw new Error(`Error loading from ${path_1.default.resolve(remoraPath)} configuration from ${configPath}: ${error.message}`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
return configs;
|
|
@@ -141,14 +141,20 @@ class ConsumerExecutorClass {
|
|
|
141
141
|
}
|
|
142
142
|
finally { if (e_1) throw e_1.error; }
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
reader.close();
|
|
144
|
+
lineReader.close();
|
|
146
145
|
// Wait for the writer to finish before renaming
|
|
147
146
|
yield new Promise((resolve, reject) => {
|
|
148
|
-
writer.on('
|
|
147
|
+
writer.on('close', resolve);
|
|
149
148
|
writer.on('error', reject);
|
|
150
149
|
writer.end();
|
|
151
150
|
});
|
|
151
|
+
// Ensure the reader is fully closed before renaming
|
|
152
|
+
if (!reader.destroyed) {
|
|
153
|
+
yield new Promise(resolve => {
|
|
154
|
+
reader.once('close', resolve);
|
|
155
|
+
reader.destroy();
|
|
156
|
+
});
|
|
157
|
+
}
|
|
152
158
|
fs_1.default.renameSync(tempWorkPath, datasetPath);
|
|
153
159
|
return newLineCount;
|
|
154
160
|
});
|
|
@@ -191,7 +197,7 @@ class ConsumerExecutorClass {
|
|
|
191
197
|
}
|
|
192
198
|
finally { if (e_2) throw e_2.error; }
|
|
193
199
|
}
|
|
194
|
-
|
|
200
|
+
lineReader.close();
|
|
195
201
|
// Write the winning records to the temp file
|
|
196
202
|
const tempWorkPath = datasetPath + '_tmp';
|
|
197
203
|
const writer = fs_1.default.createWriteStream(tempWorkPath);
|
|
@@ -200,10 +206,17 @@ class ConsumerExecutorClass {
|
|
|
200
206
|
}
|
|
201
207
|
// Wait for the writer to finish before renaming
|
|
202
208
|
yield new Promise((resolve, reject) => {
|
|
203
|
-
writer.on('
|
|
209
|
+
writer.on('close', resolve);
|
|
204
210
|
writer.on('error', reject);
|
|
205
211
|
writer.end();
|
|
206
212
|
});
|
|
213
|
+
// Ensure the reader is fully closed before renaming
|
|
214
|
+
if (!reader.destroyed) {
|
|
215
|
+
yield new Promise(resolve => {
|
|
216
|
+
reader.once('close', resolve);
|
|
217
|
+
reader.destroy();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
207
220
|
fs_1.default.renameSync(tempWorkPath, datasetPath);
|
|
208
221
|
return winners.size;
|
|
209
222
|
});
|
|
@@ -109,6 +109,8 @@ class ExecutorOrchestratorClass {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
_progress.complete();
|
|
112
|
+
if (executorResults.some(x => !Algo_1.default.hasVal(x)))
|
|
113
|
+
throw new Error(`${executorResults.filter(x => !Algo_1.default.hasVal(x)).length} worker(s) failed to produce valid results`);
|
|
112
114
|
yield this.reconcileExecutorThreadsResults(scope, executorResults, tracker);
|
|
113
115
|
// If there is more than one worker, then I need to redo the operations that are done on multiple lines (cause now the worker files have been merged together)
|
|
114
116
|
const postOperation = { totalOutputCount: null };
|
|
@@ -119,7 +121,7 @@ class ExecutorOrchestratorClass {
|
|
|
119
121
|
tracker.measure('process-distinct:main', performance.now() - counter);
|
|
120
122
|
postOperation.totalOutputCount = unifiedOutputCount;
|
|
121
123
|
}
|
|
122
|
-
if ((
|
|
124
|
+
if ((_b = consumer.options) === null || _b === void 0 ? void 0 : _b.distinctOn) {
|
|
123
125
|
counter = performance.now();
|
|
124
126
|
const unifiedOutputCount = yield ConsumerExecutor_1.default.processDistinctOn(consumer, ExecutorScope_1.default.getMainPath(scope));
|
|
125
127
|
tracker.measure('process-distinct-on:main', performance.now() - counter);
|