@vbarbarosh/node-helpers 1.1.3 → 2.0.0
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/README.md +1 -1
- package/package.json +1 -1
- package/src/array_chunk.js +1 -1
- package/src/array_chunk.test.js +2 -2
- package/src/array_gcd.js +1 -1
- package/src/array_gcd.test.js +2 -2
- package/src/array_group.js +2 -2
- package/src/array_group_map.js +1 -1
- package/src/array_index.js +1 -1
- package/src/array_index.test.js +2 -2
- package/src/array_max.js +1 -1
- package/src/array_max.test.js +2 -2
- package/src/array_min.js +1 -1
- package/src/array_min.test.js +2 -2
- package/src/array_shuffle.js +24 -0
- package/src/array_sort.js +2 -2
- package/src/array_sort.test.js +2 -2
- package/src/array_sort_other.js +2 -2
- package/src/array_sort_other.test.js +2 -2
- package/src/array_sum.js +1 -1
- package/src/array_sum.test.js +2 -2
- package/src/array_unique_last.js +1 -1
- package/src/cli.js +8 -25
- package/src/crypto_decrypt_aes256.js +2 -2
- package/src/crypto_encrypt_aes256.js +2 -2
- package/src/crypto_encrypt_aes256.test.js +3 -3
- package/src/crypto_hash_md5.js +2 -2
- package/src/crypto_hash_sha256.js +2 -2
- package/src/crypto_hash_sha256.test.js +2 -2
- package/src/crypto_hmac_sha256.js +2 -2
- package/src/fcmp_dates.js +1 -1
- package/src/fcmp_numbers.js +1 -1
- package/src/fcmp_strings.js +1 -1
- package/src/format_thousands.js +1 -1
- package/src/fs_append.js +3 -3
- package/src/fs_append_json.js +3 -3
- package/src/fs_assert_file_exists.js +2 -2
- package/src/fs_assert_file_readable.js +2 -2
- package/src/fs_copy.js +3 -3
- package/src/fs_exists.js +2 -2
- package/src/fs_fclose.js +3 -3
- package/src/fs_fi.js +6 -6
- package/src/fs_find.js +5 -5
- package/src/fs_fopen.js +3 -3
- package/src/fs_fopen_update.js +2 -2
- package/src/fs_fread.js +3 -3
- package/src/fs_fsize.js +2 -2
- package/src/fs_fstat.js +3 -3
- package/src/fs_fwrite.js +3 -3
- package/src/fs_ls.js +5 -5
- package/src/fs_lsr.js +5 -5
- package/src/fs_lstat.js +3 -3
- package/src/fs_mkdir.js +3 -3
- package/src/fs_mkdirp.js +17 -11
- package/src/fs_mkdirp.test.js +15 -0
- package/src/fs_path_basename.js +2 -2
- package/src/fs_path_dirname.js +2 -2
- package/src/fs_path_join.js +2 -2
- package/src/fs_path_resolve.js +2 -2
- package/src/fs_path_sanitize.js +2 -2
- package/src/fs_path_tempdir.js +2 -2
- package/src/fs_read.js +3 -3
- package/src/fs_read_json.js +2 -2
- package/src/fs_read_stream.js +3 -1
- package/src/fs_read_utf8.js +2 -2
- package/src/fs_readdir.js +3 -3
- package/src/fs_readlink.js +3 -3
- package/src/fs_rename.js +3 -3
- package/src/fs_rm.js +3 -3
- package/src/fs_rmdir.js +3 -3
- package/src/fs_rmrf.js +7 -7
- package/src/fs_size.js +2 -2
- package/src/fs_tempdir.js +6 -6
- package/src/fs_write.js +3 -3
- package/src/fs_write_stream.js +3 -1
- package/src/http_delete.js +2 -2
- package/src/http_get_blob.js +2 -2
- package/src/http_get_buffer.js +2 -2
- package/src/http_get_file.js +6 -6
- package/src/http_get_json.js +2 -2
- package/src/http_patch_json.js +2 -2
- package/src/http_post_json.js +2 -2
- package/src/http_post_multipart.js +3 -3
- package/src/http_post_urlencoded.js +3 -3
- package/src/http_put_file.js +7 -7
- package/src/http_put_json.js +2 -2
- package/src/identity.js +1 -1
- package/src/ignore.js +1 -1
- package/src/json_stringify_stable.js +2 -2
- package/src/now_atom.js +1 -1
- package/src/random_int.js +6 -0
- package/src/redis_connect.js +21 -0
- package/src/redis_lshift.js +8 -0
- package/src/redis_poll.js +106 -0
- package/src/redis_poll_zshift_callback_rpush.js +141 -0
- package/src/redis_poll_zshift_spawn_rpush.js +159 -0
- package/src/redis_zshift.js +9 -0
- package/src/stream_data_ln.js +1 -1
- package/src/stream_data_ln.test.js +4 -4
- package/src/stream_promise.js +2 -2
- package/src/stream_promise.test.js +3 -3
- package/src/throttle.js +1 -1
package/src/fs_mkdirp.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const fs_exists = require('./fs_exists');
|
|
2
|
+
const fs_mkdir = require('./fs_mkdir');
|
|
3
|
+
const fs_path_dirname = require('./fs_path_dirname');
|
|
4
4
|
|
|
5
5
|
async function fs_mkdirp(pathname)
|
|
6
6
|
{
|
|
7
7
|
const parents = [];
|
|
8
8
|
|
|
9
9
|
for (let p = pathname; p && p != '/'; p = fs_path_dirname(p)) {
|
|
10
|
-
|
|
11
|
-
await fs_lstat(p);
|
|
10
|
+
if (await fs_exists(p)) {
|
|
12
11
|
break;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
parents.unshift(p);
|
|
16
|
-
}
|
|
13
|
+
parents.push(p);
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
while (parents.length) {
|
|
17
|
+
try {
|
|
18
|
+
await fs_mkdir(parents.pop());
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
// Error: EEXIST: file already exists, mkdir [...]
|
|
22
|
+
if (error.code == 'EEXIST') {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
return pathname;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
module.exports = fs_mkdirp;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const assert = require('assert');
|
|
2
|
+
const fs_fi = require('./fs_fi');
|
|
3
|
+
const fs_mkdirp = require('./fs_mkdirp');
|
|
4
|
+
const fs_path_resolve = require('./fs_path_resolve');
|
|
5
|
+
const fs_tempdir = require('./fs_tempdir');
|
|
6
|
+
|
|
7
|
+
describe('fs_mkdirp', function () {
|
|
8
|
+
it('should accept empty array', async function () {
|
|
9
|
+
await fs_tempdir(async function (d) {
|
|
10
|
+
const tmp = fs_path_resolve(d, 'a/b/c/d/e');
|
|
11
|
+
await fs_mkdirp(tmp);
|
|
12
|
+
assert(await fs_fi(tmp).then(v => v.isDirectory()));
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
package/src/fs_path_basename.js
CHANGED
package/src/fs_path_dirname.js
CHANGED
package/src/fs_path_join.js
CHANGED
package/src/fs_path_resolve.js
CHANGED
package/src/fs_path_sanitize.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
const sanitize_filename = require('sanitize-filename');
|
|
2
2
|
|
|
3
3
|
function fs_path_sanitize(filename)
|
|
4
4
|
{
|
|
5
5
|
return sanitize_filename(filename);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports = fs_path_sanitize;
|
package/src/fs_path_tempdir.js
CHANGED
package/src/fs_read.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.readFile);
|
package/src/fs_read_json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const fs_read = require('./fs_read');
|
|
2
2
|
|
|
3
3
|
// XXX Should support catchReturn, e.g.
|
|
4
4
|
// fs_read_json(file).catchReturn(default_value)
|
|
@@ -7,4 +7,4 @@ function fs_read_json(file)
|
|
|
7
7
|
return fs_read(file, {encoding: 'utf8'}).then(JSON.parse);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
module.exports = fs_read_json;
|
package/src/fs_read_stream.js
CHANGED
package/src/fs_read_utf8.js
CHANGED
package/src/fs_readdir.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.readdir);
|
package/src/fs_readlink.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.readlink);
|
package/src/fs_rename.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.rename);
|
package/src/fs_rm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.unlink);
|
package/src/fs_rmdir.js
CHANGED
package/src/fs_rmrf.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const Promise = require('bluebird');
|
|
2
|
+
const fs_fi = require('./fs_fi');
|
|
3
|
+
const fs_path_resolve = require('./fs_path_resolve');
|
|
4
|
+
const fs_readdir = require('./fs_readdir');
|
|
5
|
+
const fs_rm = require('./fs_rm');
|
|
6
|
+
const fs_rmdir = require('./fs_rmdir');
|
|
7
7
|
|
|
8
8
|
async function fs_rmrf(pathname)
|
|
9
9
|
{
|
|
@@ -22,4 +22,4 @@ async function fs_rmrf(pathname)
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
module.exports = fs_rmrf;
|
package/src/fs_size.js
CHANGED
package/src/fs_tempdir.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const fs_path_resolve = require('./fs_path_resolve');
|
|
3
|
+
const fs_path_tempdir = require('./fs_path_tempdir');
|
|
4
|
+
const fs_rmrf = require('./fs_rmrf');
|
|
5
|
+
const util = require('util');
|
|
6
6
|
|
|
7
7
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
8
8
|
const mkdtemp = util.promisify(fs.mkdtemp);
|
|
@@ -39,4 +39,4 @@ async function fs_tempdir(fn)
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
module.exports = fs_tempdir;
|
package/src/fs_write.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const util = require('util');
|
|
3
3
|
|
|
4
4
|
// https://nodejs.org/api/util.html#util_util_promisify_original
|
|
5
|
-
|
|
5
|
+
module.exports = util.promisify(fs.writeFile);
|
package/src/fs_write_stream.js
CHANGED
package/src/http_delete.js
CHANGED
package/src/http_get_blob.js
CHANGED
package/src/http_get_buffer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
2
|
|
|
3
3
|
function http_get_buffer(url, options)
|
|
4
4
|
{
|
|
5
5
|
return axios.get(url, {responseType: 'arraybuffer', ...options}).then(v => v.data);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
module.exports = http_get_buffer;
|
package/src/http_get_file.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const stream = require('stream');
|
|
4
|
+
const util = require('util');
|
|
5
5
|
|
|
6
|
-
const stream_finished = promisify(stream.finished);
|
|
6
|
+
const stream_finished = util.promisify(stream.finished);
|
|
7
7
|
|
|
8
8
|
// https://stackoverflow.com/a/61269447
|
|
9
9
|
function http_get_file(url, out_file, options)
|
|
@@ -14,4 +14,4 @@ function http_get_file(url, out_file, options)
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
module.exports = http_get_file;
|
package/src/http_get_json.js
CHANGED
package/src/http_patch_json.js
CHANGED
package/src/http_post_json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const FormData = require('form-data');
|
|
2
|
+
const axios = require('axios');
|
|
3
3
|
|
|
4
4
|
// Provide examples for the following common tasks:
|
|
5
5
|
//
|
|
@@ -60,4 +60,4 @@ function http_post_multipart(url, items, options)
|
|
|
60
60
|
return Promise.resolve(axios.post(url, form, options)).then(v => v.data);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
module.exports = http_post_multipart;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
const qs = require('querystring');
|
|
3
3
|
|
|
4
4
|
function http_post_urlencoded(url, body, options)
|
|
5
5
|
{
|
|
6
6
|
return axios.post(url, qs.stringify(body), options).then(v => v.data);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
module.exports = http_post_urlencoded;
|
package/src/http_put_file.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const fs_size = require('./fs_size');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
5
5
|
|
|
6
|
-
async function http_put_file(url, file, options)
|
|
6
|
+
async function http_put_file(url, file, options = {})
|
|
7
7
|
{
|
|
8
8
|
// <?xml version="1.0" encoding="UTF-8"?>
|
|
9
9
|
// <Error>
|
|
@@ -17,7 +17,7 @@ async function http_put_file(url, file, options)
|
|
|
17
17
|
const total = await fs_size(file);
|
|
18
18
|
return new Promise(function (resolve, reject) {
|
|
19
19
|
const chunks = [];
|
|
20
|
-
const request = (url.startsWith('http:') ? http : https).request(url, {method: 'PUT', headers: {'Content-Length': total}}, function (response) {
|
|
20
|
+
const request = (url.startsWith('http:') ? http : https).request(url, {method: 'PUT', headers: {...options.headers, 'Content-Length': total}}, function (response) {
|
|
21
21
|
response.on('error', reject);
|
|
22
22
|
if (options.progress_download) {
|
|
23
23
|
const total_download = response.headers['content-length'] ? parseInt(response.headers['content-length']) : null;
|
|
@@ -57,4 +57,4 @@ async function http_put_file(url, file, options)
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
module.exports = http_put_file;
|
package/src/http_put_json.js
CHANGED
package/src/identity.js
CHANGED
package/src/ignore.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
const json_stringify_stable = require('json-stable-stringify');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module.exports = json_stringify_stable;
|
package/src/now_atom.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const Redis = require('redis');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* tls://11.11.11.11:6378?ip-google=11.11.11.11&ip-external=22.22.22.22&password=xx-xx-xx&ssl[verify_peer]=0&ssl[verify_peer_name]=0
|
|
5
|
+
*
|
|
6
|
+
* @param url
|
|
7
|
+
* @returns {*}
|
|
8
|
+
*/
|
|
9
|
+
function redis_connect(url)
|
|
10
|
+
{
|
|
11
|
+
if (url.match(/^tls:/)) {
|
|
12
|
+
return Redis.createClient(url.replace(/^tls:/, 'rediss:'), {
|
|
13
|
+
tls: {
|
|
14
|
+
rejectUnauthorized: false,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return Redis.createClient(url.replace(/^tcp:/, 'redis:'));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = redis_connect;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const Promise = require('bluebird');
|
|
2
|
+
const random_int = require('./random_int');
|
|
3
|
+
const redis_zshift = require('./redis_zshift');
|
|
4
|
+
|
|
5
|
+
async function redis_poll(options)
|
|
6
|
+
{
|
|
7
|
+
const {log, version} = options;
|
|
8
|
+
const {
|
|
9
|
+
poll_message,
|
|
10
|
+
push_response,
|
|
11
|
+
process_message,
|
|
12
|
+
log_waiter_begin,
|
|
13
|
+
log_waiter_end,
|
|
14
|
+
log_waiter_sleep,
|
|
15
|
+
log_waiter_rpush,
|
|
16
|
+
log_waiter_error,
|
|
17
|
+
log_waiter_error_parse,
|
|
18
|
+
log_waiter_error_no_uid,
|
|
19
|
+
} = options;
|
|
20
|
+
|
|
21
|
+
log(`[${log_waiter_begin}] v${version}`);
|
|
22
|
+
try {
|
|
23
|
+
for (let iter = 1; iter <= 24*60*60; ++iter) {
|
|
24
|
+
|
|
25
|
+
// const message_string = await redis.lpop_p(redis_input_queue);
|
|
26
|
+
const message = await poll_message();
|
|
27
|
+
if (!message) {
|
|
28
|
+
const ms = random_int(500, 1500);
|
|
29
|
+
log(`[${log_waiter_sleep}] ${ms}ms`);
|
|
30
|
+
await Promise.delay(ms);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const uid = message.uid;
|
|
36
|
+
|
|
37
|
+
if (!uid) {
|
|
38
|
+
log(`[${log_waiter_error_no_uid}] uid is missed; skipped`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!message.expires_at) {
|
|
42
|
+
throw new Error('expires_at is missed');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// This is necessary because we use signed urls which has limited lifetime.
|
|
46
|
+
// Basically, `expires_at` tell when signed url will be expired.
|
|
47
|
+
if (new Date(message.expires_at).getTime() <= new Date().getTime()) {
|
|
48
|
+
throw new Error('Expired');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const value = await worker(log.spawn(), message, options);
|
|
52
|
+
await push_response({uid: message.uid, version, type: 'resolve', value});
|
|
53
|
+
|
|
54
|
+
log(`[${log_waiter_rpush}]`);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const response = {uid: message.uid, version, type: 'reject', value: `${(error && (error.stack || error.message)) || 'Error N/A'}`};
|
|
58
|
+
log(`[${log_waiter_error}] ${JSON.stringify({response})}`);
|
|
59
|
+
await push_response(response);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
log(`[${log_waiter_end}]`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function worker(log, message, options)
|
|
69
|
+
{
|
|
70
|
+
const {redis, redis_output_queue, spawn_command, version} = options;
|
|
71
|
+
const {
|
|
72
|
+
callback,
|
|
73
|
+
log_worker_begin,
|
|
74
|
+
log_worker_end_ok,
|
|
75
|
+
log_worker_end_error,
|
|
76
|
+
log_worker_stdout,
|
|
77
|
+
log_worker_stderr,
|
|
78
|
+
log_worker_user_friendly_status,
|
|
79
|
+
} = options;
|
|
80
|
+
|
|
81
|
+
log(`[${log_worker_begin}] ${message.uid}`);
|
|
82
|
+
|
|
83
|
+
const uid = message.uid;
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
// GOTCHA
|
|
87
|
+
// Promise won't update its status until at least one message would
|
|
88
|
+
// be taken from output queue. Pushing generic "Started...." message
|
|
89
|
+
// will tell the promise to refresh its status.
|
|
90
|
+
await user_friendly_status('Started...');
|
|
91
|
+
const out = await callback({message, log: log.spawn(), user_friendly_status});
|
|
92
|
+
log(`[${log_worker_end_ok}]`);
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
log(`[${log_worker_end_error}] ${error.message}`);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function user_friendly_status(value) {
|
|
101
|
+
log(`[${log_worker_user_friendly_status}] ${value}`);
|
|
102
|
+
await redis.rpush_p(redis_output_queue, JSON.stringify({uid, version, type: 'user_friendly_status', value}));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = redis_poll;
|