vaporous 0.0.8 → 0.0.9
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/package.json +1 -1
- package/src/checkpoints.js +20 -22
package/package.json
CHANGED
package/src/checkpoints.js
CHANGED
|
@@ -39,33 +39,31 @@ module.exports = {
|
|
|
39
39
|
if (this.activeCheckpointRestore && name !== this.activeCheckpointRestore) throw new Error('Only one checkpoint restoration can be active at a time')
|
|
40
40
|
|
|
41
41
|
Object.keys(this.checkpoints).forEach(async (checkpoint) => {
|
|
42
|
+
|
|
42
43
|
const checkpointEvents = this.checkpoints[checkpoint]
|
|
43
44
|
|
|
44
45
|
for (const event in checkpointEvents) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
resolve()
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
thisEvent._checkpoint = checkpoint;
|
|
66
|
-
await writeData(JSON.stringify(thisEvent) + '\n')
|
|
46
|
+
const thisEvent = checkpointEvents[event]
|
|
47
|
+
const handlerKey = `${checkpoint}.${name}.${thisEvent[partitionBy]}.vpck`
|
|
48
|
+
|
|
49
|
+
if (!fileHandler[handlerKey]) fileHandler[handlerKey] = fs.createWriteStream(`./${handlerKey}`)
|
|
50
|
+
const thisFileHandler = fileHandler[handlerKey]
|
|
51
|
+
|
|
52
|
+
function writeData(data) {
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
const status = thisFileHandler.write(data)
|
|
55
|
+
if (!status) {
|
|
56
|
+
thisFileHandler.once('drain', () => resolve(writeData(data)))
|
|
57
|
+
} else {
|
|
58
|
+
resolve()
|
|
59
|
+
}
|
|
60
|
+
})
|
|
67
61
|
}
|
|
62
|
+
|
|
63
|
+
thisEvent._checkpoint = checkpoint;
|
|
64
|
+
await writeData(JSON.stringify(thisEvent) + '\n')
|
|
68
65
|
}
|
|
66
|
+
|
|
69
67
|
})
|
|
70
68
|
|
|
71
69
|
this.activeCheckpointRestore = null;
|