Skip to content

Commit c383cb5

Browse files
authored
Merge pull request #3094 from Countly/hotfix/populator-push
[push] Missing files
2 parents ea11b5c + fb9e945 commit c383cb5

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const { DoFlush } = require('./do_flush');
2+
3+
/**
4+
* Transform which only closes once syn frame is received
5+
*/
6+
class DoFinish extends DoFlush {
7+
8+
/**
9+
* Constructor
10+
*
11+
* @param {object} opts transform options
12+
*/
13+
constructor(opts) {
14+
super(opts);
15+
}
16+
17+
/**
18+
* A method to be overridden
19+
*
20+
* @param {function} callback finish callback
21+
*/
22+
do_final(/*callback*/) {
23+
throw new Error('Must be overridden');
24+
}
25+
26+
/**
27+
* Finish the stream by flushing it and then delegating the finish job to do_final() method
28+
*
29+
* @param {function} callback finish callback
30+
*/
31+
_final(callback) {
32+
this.log.d('finishing');
33+
this.do_final(finishErr => {
34+
if (finishErr) {
35+
this.log.w('finish error', finishErr);
36+
}
37+
else {
38+
this.log.d('finished successfully');
39+
}
40+
callback(finishErr);
41+
});
42+
}
43+
}
44+
45+
module.exports = { DoFinish };
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { Transform } = require('stream');
2+
3+
/**
4+
* Transform which only closes once syn frame is received
5+
*/
6+
class DoFlush extends Transform {
7+
8+
/**
9+
* Constructor
10+
*
11+
* @param {object} opts transform options
12+
*/
13+
constructor(opts) {
14+
super(opts);
15+
}
16+
17+
/**
18+
* A method to be overridden
19+
* @param {function} callback flush callback
20+
*/
21+
do_flush(/*callback*/) {
22+
throw new Error('Must be overridden');
23+
}
24+
25+
/**
26+
* Flush the stream delegating the job to do_flush() method
27+
*
28+
* @param {function} callback flush callback
29+
*/
30+
_flush(callback) {
31+
this.log.d('flushing');
32+
this.do_flush(err => {
33+
if (err) {
34+
this.log.w('flush error', err);
35+
}
36+
else {
37+
this.log.d('flushed successfully');
38+
}
39+
callback(err);
40+
});
41+
}
42+
}
43+
44+
module.exports = { DoFlush };

0 commit comments

Comments
 (0)