queueobj 12.0.18 → 14.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/.github/workflows/node.js.yml +1 -4
- package/README.md +101 -73
- package/app.js +143 -232
- package/lib/appenders/all.js +1 -1
- package/lib/appenders/base.js +3 -4
- package/lib/appenders/bottom_one.js +1 -1
- package/lib/appenders/func_all.js +1 -1
- package/lib/appenders/sync.js +1 -1
- package/lib/appenders/sync_all.js +1 -1
- package/lib/appenders/top_one.js +1 -1
- package/lib/appenders/version.js +1 -1
- package/package.json +33 -15
- package/test/app.js +15 -51
- package/test/package.js +33 -15
- package/tests/all.js +85 -0
- package/tests/appenders/all.js +17 -0
- package/tests/appenders/base.js +189 -0
- package/tests/appenders/bottom_one.js +17 -0
- package/tests/appenders/func_all.js +17 -0
- package/tests/appenders/name.js +17 -0
- package/tests/appenders/status.js +17 -0
- package/tests/appenders/sync.js +17 -0
- package/tests/appenders/sync_all.js +17 -0
- package/tests/appenders/top_one.js +17 -0
- package/tests/appenders/version.js +17 -0
- package/tests/bottom_one.js +86 -0
- package/tests/files.js +108 -0
- package/tests/func_all.js +94 -0
- package/tests/json_all.js +107 -0
- package/tests/json_bottom_one.js +108 -0
- package/tests/json_func_all.js +109 -0
- package/tests/json_name_matching.js +109 -0
- package/tests/json_name_non_matching.js +109 -0
- package/tests/json_status_matching.js +110 -0
- package/tests/json_status_non_matching.js +110 -0
- package/tests/json_top_one.js +108 -0
- package/tests/json_version_matching.js +110 -0
- package/tests/json_version_non_matching.js +110 -0
- package/tests/name_matching.js +90 -0
- package/tests/name_non_matching.js +90 -0
- package/tests/status_matching.js +90 -0
- package/tests/status_non_matching.js +90 -0
- package/tests/top_one.js +85 -0
- package/tests/version_matching.js +90 -0
- package/tests/version_non_matching.js +90 -0
- package/test/base.js +0 -22
- package/tests/test_all.js +0 -36
- package/tests/test_bottom_one.js +0 -28
- package/tests/test_func_all.js +0 -43
- package/tests/test_name.js +0 -86
- package/tests/test_status.js +0 -86
- package/tests/test_sync_all.js +0 -79
- package/tests/test_top_one.js +0 -29
- package/tests/test_version.js +0 -97
|
@@ -78,8 +78,5 @@ jobs:
|
|
|
78
78
|
run: npm ls --depth=0 --dev && npm ls --depth=0 --prod
|
|
79
79
|
|
|
80
80
|
- run: npm run build --if-present
|
|
81
|
+
- run: npm run test_files
|
|
81
82
|
- run: npm run test_all
|
|
82
|
-
- run: npm run test_bottom_one
|
|
83
|
-
- run: npm run test_top_one
|
|
84
|
-
- run: npm run test_func_all
|
|
85
|
-
- run: npm run test_sync_all
|
package/README.md
CHANGED
|
@@ -5,18 +5,26 @@
|
|
|
5
5
|
|
|
6
6
|
[](https://nodei.co/npm/queueobj/)
|
|
7
7
|
|
|
8
|
-
Queue javascript objects dynamically then process the queue according to the appender.
|
|
8
|
+
Queue javascript objects dynamically then process the queue according to the appender. All appenders are handled synchronously.
|
|
9
9
|
|
|
10
10
|
Included tag appenders:
|
|
11
11
|
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* top_one -
|
|
15
|
-
* bottom_one -
|
|
16
|
-
*
|
|
17
|
-
* status -
|
|
18
|
-
* name -
|
|
19
|
-
* version -
|
|
12
|
+
* files - See if inputed files exists.
|
|
13
|
+
* all - process all added objects.
|
|
14
|
+
* top_one - process only the object in the 0(zero) position of the process array.
|
|
15
|
+
* bottom_one - process only the object in the last position of the process array.
|
|
16
|
+
* func_all - process custom function names in created objects. Custom processing names can be used in any appender, this is just one example.
|
|
17
|
+
* status - queue and process all objects by status.
|
|
18
|
+
* name - queue and process all objects by name.
|
|
19
|
+
* version - queue and process all objects by version.
|
|
20
|
+
|
|
21
|
+
* json_all - process a class object per json input array variables.
|
|
22
|
+
* json_top_one - process a class object per the first json input array variable.
|
|
23
|
+
* json_bottom_one - process a class object per the last json input array variable.
|
|
24
|
+
* json_func_all - process custom function names in created objects. Custom processing names can be used in any json appender, this is just one example.
|
|
25
|
+
* json_status - queue and process all objects by status.
|
|
26
|
+
* json_name - queue and process all objects by name.
|
|
27
|
+
* json_version - queue and process all objects by version.
|
|
20
28
|
|
|
21
29
|
Mocha Test
|
|
22
30
|
---------
|
|
@@ -27,14 +35,27 @@ npm test
|
|
|
27
35
|
General Setup Test
|
|
28
36
|
---------
|
|
29
37
|
```
|
|
38
|
+
npm run test_files
|
|
30
39
|
npm run test_all
|
|
31
40
|
npm run test_top_one
|
|
32
41
|
npm run test_bottom_one
|
|
33
42
|
npm run test_func_all
|
|
34
|
-
npm run
|
|
35
|
-
npm run
|
|
36
|
-
npm run
|
|
37
|
-
npm run
|
|
43
|
+
npm run test_status_matching
|
|
44
|
+
npm run test_status_non_matching
|
|
45
|
+
npm run test_name_matching
|
|
46
|
+
npm run test_name_non_matching
|
|
47
|
+
npm run test_version_matching
|
|
48
|
+
npm run test_version_non_matching
|
|
49
|
+
npm run test_json_all
|
|
50
|
+
npm run test_json_top_one
|
|
51
|
+
npm run test_json_bottom_one
|
|
52
|
+
npm run test_json_func_all
|
|
53
|
+
npm run test_json_status_matching
|
|
54
|
+
npm run test_json_status_non_matching
|
|
55
|
+
npm run test_json_version_matching
|
|
56
|
+
npm run test_json_version_non_matching
|
|
57
|
+
npm run test_json_name_matching
|
|
58
|
+
npm run test_json_name_non_matching
|
|
38
59
|
|
|
39
60
|
```
|
|
40
61
|
|
|
@@ -42,76 +63,83 @@ Usage
|
|
|
42
63
|
---------
|
|
43
64
|
```js
|
|
44
65
|
|
|
45
|
-
var colors = require('colors')
|
|
46
66
|
var queue = require("queueobj");
|
|
47
67
|
|
|
48
|
-
class test1 {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
68
|
+
var tst1 = class test1 {
|
|
69
|
+
constructor(props) {
|
|
70
|
+
let t = this, fname = "test_all.test1.constructor"
|
|
71
|
+
t.log = props.log
|
|
72
|
+
t.id = props.id
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
process(callback) {
|
|
76
|
+
let t = this, fname = "test_all.test1.process"
|
|
77
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
78
|
+
callback({ success: { msg: `processing all test1` } })
|
|
79
|
+
}
|
|
61
80
|
}
|
|
62
81
|
|
|
63
|
-
class test2 {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
82
|
+
var tst2 = class test2 {
|
|
83
|
+
constructor(props) {
|
|
84
|
+
let t = this, fname = "test_all.test2.constructor"
|
|
85
|
+
t.log = props.log
|
|
86
|
+
t.id = props.id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
process(callback) {
|
|
90
|
+
let t = this, fname = "test_all.test2.process"
|
|
91
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
callback({ success: { msg: `processing all test2` } })
|
|
94
|
+
}, 4000)
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
|
|
80
|
-
class test3 {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
var tst3 = class test3 {
|
|
99
|
+
constructor(props) {
|
|
100
|
+
let t = this, fname = "test_all.test3.constructor"
|
|
101
|
+
t.log = props.log
|
|
102
|
+
t.id = props.id
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
process(callback) {
|
|
106
|
+
let t = this, fname = "test_all.test3.process"
|
|
107
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
108
|
+
// callback({success: { msg: `processing all test3` }})
|
|
109
|
+
callback({ error: { msg: `there is some problem thrown here on test3` } })
|
|
110
|
+
}
|
|
89
111
|
}
|
|
90
112
|
|
|
91
|
-
class test4 {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
custom_function(callback) {
|
|
99
|
-
let msg = `custom func problem here id(${this.id})`
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
// callback({error: {msg: msg}}) //this will show errors
|
|
102
|
-
callback({success: {msg: `processing all (${this.id})}`}}) //this will show no errors
|
|
103
|
-
}, 3000)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
let tst4 = new test4()
|
|
107
|
-
let qObj = new queue(), props = { appender: 'name' }
|
|
113
|
+
var tst4 = class test4 {
|
|
114
|
+
constructor(props) {
|
|
115
|
+
let t = this, fname = "test_all.test4.constructor"
|
|
116
|
+
t.log = props.log
|
|
117
|
+
t.id = props.id
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
process(callback) {
|
|
122
|
+
let t = this, fname = "test_all.test4.process"
|
|
123
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
124
|
+
callback({ success: { msg: `processing all test4` } })
|
|
125
|
+
}
|
|
126
|
+
}
|
|
110
127
|
|
|
111
|
-
qObj
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
var qObj = new queue()
|
|
129
|
+
|
|
130
|
+
qObj.init().process({
|
|
131
|
+
appender: "all",
|
|
132
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
133
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
134
|
+
}).then((success) => {
|
|
135
|
+
qObj.logMsg({ msg: `test success: {msg: "all objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
136
|
+
}, (error) => {
|
|
137
|
+
if (typeof error == "string") {
|
|
138
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
139
|
+
} else {
|
|
140
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
141
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
142
|
+
}
|
|
115
143
|
})
|
|
116
144
|
|
|
117
145
|
```
|
package/app.js
CHANGED
|
@@ -1,276 +1,187 @@
|
|
|
1
1
|
/* @author Jim Manton: jrman@risebroadband.net
|
|
2
|
-
* @since
|
|
2
|
+
* @since 2023-01-15
|
|
3
3
|
* Main processing app
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
bottom_one = require('./lib/appenders/bottom_one'),
|
|
11
|
-
sync_all = require('./lib/appenders/sync_all'),
|
|
12
|
-
status = require('./lib/appenders/status'),
|
|
13
|
-
name = require('./lib/appenders/name'),
|
|
14
|
-
version = require('./lib/appenders/version')
|
|
6
|
+
let base_queue = require("base-queue"),
|
|
7
|
+
log_queue = require("log-queue"),
|
|
8
|
+
fs = require('fs'),
|
|
9
|
+
validPath = require('valid-path')
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
const { memoryUsage } = require('process')
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
t.id = 0
|
|
22
|
-
t.appenders_dir = './lib/appenders/'
|
|
23
|
-
t.props = {}
|
|
24
|
-
t.all = null
|
|
25
|
-
t.top_one = null
|
|
26
|
-
t.bottom_one = null
|
|
27
|
-
t.array = null
|
|
28
|
-
t.status = null
|
|
29
|
-
t.version = null
|
|
30
|
-
t.stats = false
|
|
31
|
-
t.sync_all = null
|
|
32
|
-
t.name = null
|
|
33
|
-
t.func_all = null
|
|
34
|
-
t.objs = []
|
|
35
|
-
t.resolve = null
|
|
36
|
-
t.reject = null
|
|
13
|
+
var log_data = [
|
|
14
|
+
{ props: { id: 100, name: "console_basic", absolute_path: __filename, check: true } }
|
|
15
|
+
]
|
|
37
16
|
|
|
38
|
-
t.load = t.load.bind(this)
|
|
39
|
-
t.process = t.process.bind(this)
|
|
40
|
-
t.getParent = t.getParent.bind(this)
|
|
41
|
-
t.getObjectToProcess = t.getObjectToProcess.bind(this)
|
|
42
|
-
t.getObjectById = t.getObjectById.bind(this)
|
|
43
|
-
t.getObjs = t.getObjs.bind(this)
|
|
44
|
-
t.logMsg = t.logMsg.bind(this)
|
|
45
|
-
return t
|
|
46
|
-
} catch (e) {
|
|
47
|
-
e.message = "queueObj app.js constructor error: " + e.message
|
|
48
|
-
throw (e)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
17
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
var log_object = class log_obj {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
let t = this
|
|
21
|
+
t.id = props.id
|
|
22
|
+
t.log = props.log
|
|
23
|
+
t.name = props.name
|
|
24
|
+
t.path = props.relative_path
|
|
25
|
+
t.absolute_path = props.absolute_path
|
|
26
|
+
t.status = 'init'
|
|
27
|
+
t.errors = false
|
|
28
|
+
t.error_msg = 'none'
|
|
55
29
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
t.objs[i].id == id) {
|
|
62
|
-
return t.objs[i]
|
|
63
|
-
}
|
|
30
|
+
t.process = t.process.bind(t)
|
|
31
|
+
t.do_checks = t.do_checks.bind(t)
|
|
32
|
+
|
|
33
|
+
if (props.check) {
|
|
34
|
+
t.do_checks()
|
|
64
35
|
}
|
|
65
|
-
|
|
36
|
+
|
|
37
|
+
return t
|
|
66
38
|
}
|
|
67
39
|
|
|
68
|
-
|
|
69
|
-
let t = this,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
40
|
+
do_checks() {
|
|
41
|
+
let t = this, path_to_check,
|
|
42
|
+
last_item = t.absolute_path.split("\\").pop(),
|
|
43
|
+
check_file = t.absolute_path.split(last_item)[0], check_path = t.path.split('../')
|
|
44
|
+
|
|
45
|
+
check_file = check_file.replace(/\\/g, "/");
|
|
46
|
+
path_to_check = validPath(t.path);
|
|
47
|
+
|
|
48
|
+
if (!path_to_check.valid) {
|
|
49
|
+
t.errors = true
|
|
50
|
+
t.error_msg = `id = ${t.id} name(${t.name}) Error in ${path_to_check.data.input}: ${path_to_check.error})`
|
|
76
51
|
}
|
|
77
|
-
return null
|
|
78
|
-
}
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
// check_path.map((dat, i) => {
|
|
54
|
+
// if (/^[a-zA-Z._]+$/.test(dat)) {
|
|
55
|
+
// if (dat != '.' || dat != '..')
|
|
56
|
+
// check_file += dat + '/'
|
|
57
|
+
// }
|
|
58
|
+
// })
|
|
59
|
+
// check_file = check_file.slice(0, -1)
|
|
60
|
+
check_file += check_path[1]
|
|
61
|
+
check_file += `${t.name}.js`
|
|
62
|
+
try {
|
|
63
|
+
if (!fs.existsSync(check_file)) {
|
|
64
|
+
t.errors = true
|
|
65
|
+
t.error_msg = `id = ${t.id} name(${t.name}) file (${check_file} does not exist)`
|
|
87
66
|
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
e.message = "file_obj do_checks error: " + e.message
|
|
69
|
+
throw (e)
|
|
88
70
|
}
|
|
89
|
-
return null
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
count() {
|
|
93
|
-
return this.objs.length
|
|
94
71
|
}
|
|
95
72
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
process(callback) {
|
|
74
|
+
let t = this
|
|
75
|
+
if (t.errors)
|
|
76
|
+
callback({ error: {msg: t.error_msg} })
|
|
77
|
+
else {
|
|
78
|
+
callback({ success: {msg: `id = ${t.id} name(${t.name}) success`} })
|
|
79
|
+
}
|
|
100
80
|
}
|
|
81
|
+
}
|
|
101
82
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
exports = module.exports = class QueueObj {
|
|
84
|
+
constructor() {
|
|
85
|
+
var t = this, fname = 'QueueObj.constructor'
|
|
86
|
+
try {
|
|
87
|
+
t.promise = null
|
|
88
|
+
t.resolve = null
|
|
89
|
+
t.reject = null
|
|
90
|
+
t.promise_2q = null
|
|
91
|
+
t.resolve_2q = null
|
|
92
|
+
t.reject_2q = null
|
|
93
|
+
t.successMsg = ''
|
|
94
|
+
t.log_queue = null
|
|
105
95
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
t.logMsg = t.logMsg.bind(t)
|
|
97
|
+
t.init = t.init.bind(t)
|
|
98
|
+
t.process = t.process.bind(t)
|
|
99
|
+
t.getFileObject = t.getFileObject.bind(t)
|
|
109
100
|
|
|
110
|
-
|
|
111
|
-
return this.objs[itm]
|
|
112
|
-
}
|
|
101
|
+
// t.logMsg(`QueueObj.constructor`.debug)
|
|
113
102
|
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
return t
|
|
104
|
+
} catch (e) {
|
|
105
|
+
e.message = `QueueObj app.js constructor error: ${e.message}`.error
|
|
106
|
+
console.log(e.message)
|
|
107
|
+
}
|
|
116
108
|
}
|
|
117
109
|
|
|
118
|
-
|
|
110
|
+
init() {
|
|
111
|
+
var t = this, fname = `QueueObj.init`
|
|
119
112
|
try {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
t.all = new all(props)
|
|
130
|
-
break
|
|
131
|
-
case 'top_one':
|
|
132
|
-
t.top_one = new top_one(props)
|
|
133
|
-
break
|
|
134
|
-
case 'bottom_one':
|
|
135
|
-
t.bottom_one = new bottom_one(props)
|
|
136
|
-
break
|
|
137
|
-
case 'func_all':
|
|
138
|
-
t.func_all = new func_all(props)
|
|
139
|
-
break
|
|
140
|
-
case 'array':
|
|
141
|
-
t.array = new array(props)
|
|
142
|
-
break
|
|
143
|
-
case 'status':
|
|
144
|
-
t.status = new status(props)
|
|
145
|
-
break
|
|
146
|
-
case 'version':
|
|
147
|
-
t.version = new version(props)
|
|
148
|
-
break
|
|
149
|
-
case 'sync_all':
|
|
150
|
-
t.sync_all = new sync_all(props)
|
|
151
|
-
break
|
|
152
|
-
case 'name':
|
|
153
|
-
t.name = new name(props)
|
|
154
|
-
break
|
|
155
|
-
default:
|
|
156
|
-
throw new Error(`appender(${props.appender}) not found`)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return t
|
|
160
|
-
}
|
|
113
|
+
t.promise = new Promise((resolve, reject) => {
|
|
114
|
+
t.resolve = resolve
|
|
115
|
+
t.reject = reject
|
|
116
|
+
})
|
|
117
|
+
t.promise_2q= new Promise((resolve, reject) => {
|
|
118
|
+
t.resolve_2q = resolve
|
|
119
|
+
t.reject_2q = reject
|
|
120
|
+
})
|
|
121
|
+
return t
|
|
161
122
|
} catch (e) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
123
|
+
t.logMsg({ msg: `${fname} error: (${e.message})`.error, type: 'error' })
|
|
124
|
+
// e.message = `QueueObj app.js constructor error: ${e.message}`.error
|
|
125
|
+
// console.log(e.message)
|
|
165
126
|
}
|
|
166
127
|
}
|
|
167
128
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
if (t.all != null) {
|
|
172
|
-
obj._getProperty = (o) => {
|
|
173
|
-
return 'all'
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (t.top_one != null) {
|
|
177
|
-
obj._getProperty = (o) => {
|
|
178
|
-
return 'top_one'
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (t.bottom_one != null) {
|
|
182
|
-
t.objs = []
|
|
183
|
-
obj._getProperty = (o) => {
|
|
184
|
-
return 'bottom_one'
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (t.func_all != null) {
|
|
188
|
-
obj._getProperty = (o) => {
|
|
189
|
-
return 'func_all'
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (t.sync_all != null) {
|
|
193
|
-
obj._getProperty = (o) => {
|
|
194
|
-
return 'sync_all'
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (t.name != null) {
|
|
198
|
-
obj._getProperty = (o) => {
|
|
199
|
-
return 'name'
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (typeof obj.status != 'undefined') {
|
|
203
|
-
obj._getProperty = (o) => {
|
|
204
|
-
return o.status
|
|
205
|
-
}
|
|
129
|
+
process(props = {}) {
|
|
130
|
+
let t = this, fname = `app.process`
|
|
206
131
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
obj._getProperty = (o) => {
|
|
210
|
-
return o.name
|
|
211
|
-
}
|
|
132
|
+
// if (typeof props.data_to_process_array == 'undefined')
|
|
133
|
+
// t.reject('base_queue no props.data_to_process_array')
|
|
212
134
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
135
|
+
if (typeof props.appender == 'undefined')
|
|
136
|
+
t.reject('base_queue no props.appender')
|
|
137
|
+
|
|
138
|
+
if (typeof props.process_objects == 'undefined')
|
|
139
|
+
t.reject(`props.process_objects not defined`)
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
t.log_queue = new log_queue({
|
|
143
|
+
parent: t,
|
|
144
|
+
relative_path: "../base_queue/appenders/log/",
|
|
145
|
+
exclude_logMsg: props.exclude_logMsg,
|
|
146
|
+
resolve: t.resolve,
|
|
147
|
+
reject: t.reject
|
|
148
|
+
}).init({
|
|
149
|
+
appender: "console_basic",
|
|
150
|
+
process_objects: [log_object],
|
|
151
|
+
data_to_process_array: log_data
|
|
152
|
+
})
|
|
153
|
+
t.base_queue = new base_queue({
|
|
154
|
+
parent: t,
|
|
155
|
+
relative_path: "./appenders/",
|
|
156
|
+
logMsg: t.logMsg,
|
|
157
|
+
resolve: t.resolve_2q,
|
|
158
|
+
reject: t.reject_2q
|
|
159
|
+
}).load(props).process()
|
|
160
|
+
return t.promise_2q
|
|
227
161
|
} catch (e) {
|
|
228
|
-
|
|
229
|
-
t.logMsg(e.message.red)
|
|
230
|
-
throw (e)
|
|
162
|
+
console.log(`${fname} error: (${e.message})`)
|
|
231
163
|
}
|
|
232
164
|
}
|
|
233
165
|
|
|
234
|
-
|
|
235
|
-
return this
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
getObjs() {
|
|
239
|
-
return this.objs
|
|
166
|
+
getFileObject() {
|
|
167
|
+
return this.qJson.get_class_obj_array()
|
|
240
168
|
}
|
|
241
169
|
|
|
242
|
-
|
|
170
|
+
logMsg(props = { msg: '', type: '' }) {
|
|
171
|
+
let t = this, fname = "QueueObj.logMsg"
|
|
243
172
|
try {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
case 'func_all':
|
|
253
|
-
return t.func_all.process(props)
|
|
254
|
-
case 'sync':
|
|
255
|
-
case 'sync_all':
|
|
256
|
-
return t.sync_all.process(props)
|
|
257
|
-
case 'name':
|
|
258
|
-
return t.name.process(props)
|
|
259
|
-
case 'status':
|
|
260
|
-
return t.status.process(props)
|
|
261
|
-
case 'version':
|
|
262
|
-
return t.version.process(props)
|
|
263
|
-
default:
|
|
264
|
-
throw new Error(`nothing to process`)
|
|
173
|
+
if (typeof props.msg == "undefined")
|
|
174
|
+
throw new Error(`no msg property in (${JSON.stringify(props)}) `)
|
|
175
|
+
if (typeof props.type == "undefined")
|
|
176
|
+
throw new Error(`no type property in (${JSON.stringify(props)}) `)
|
|
177
|
+
if (t.log_queue != null && typeof t.log_queue.logMsg != 'undefined') {
|
|
178
|
+
t.log_queue.logMsg(props)
|
|
179
|
+
} else {
|
|
180
|
+
throw new Error(`t.log_queue does not exist`)
|
|
265
181
|
}
|
|
266
182
|
} catch (e) {
|
|
267
|
-
e.message =
|
|
268
|
-
t.
|
|
269
|
-
throw (e)
|
|
183
|
+
e.message = `${fname} error: ${e.message})`
|
|
184
|
+
t.reject(e.message)
|
|
270
185
|
}
|
|
271
186
|
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
exports = module.exports = function (props) {
|
|
275
|
-
return new QueueObj(props)
|
|
276
187
|
}
|