file-obj-queue 2.0.5 → 3.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/{github-actions-demo.yml → github-actions.yml} +1 -1
- package/.github/workflows/node.js.yml +1 -0
- package/LICENSE +1 -1
- package/README.md +132 -7
- package/app.js +155 -40
- package/lib/appenders/all.js +17 -0
- package/lib/appenders/base.js +189 -0
- package/lib/appenders/bottom_one.js +17 -0
- package/lib/appenders/func_all.js +17 -0
- package/lib/appenders/name.js +17 -0
- package/lib/appenders/status.js +17 -0
- package/lib/appenders/sync.js +17 -0
- package/lib/appenders/sync_all.js +17 -0
- package/lib/appenders/top_one.js +17 -0
- package/lib/appenders/version.js +17 -0
- package/package.json +24 -3
- package/test/app.js +5 -1
- package/test/package.js +25 -3
- package/tests/all.js +85 -0
- package/tests/appenders/all.js +1 -1
- package/tests/appenders/base.js +1 -1
- package/tests/appenders/bottom_one.js +1 -1
- package/tests/appenders/func_all.js +1 -1
- package/tests/appenders/sync.js +1 -1
- package/tests/appenders/sync_all.js +1 -1
- package/tests/appenders/top_one.js +1 -1
- package/tests/appenders/version.js +1 -1
- package/tests/bottom_one.js +86 -0
- package/tests/files.js +50 -32
- 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/base_queue/app.js +0 -146
- package/base_queue/appenders/base.js +0 -77
- package/base_queue/appenders/json_all.js +0 -70
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "status.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.status = "init"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "status.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing all test1` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "status.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.status = "step 1"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "status.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing all test2` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "status.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.status = "remove"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "status.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing all test3` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on test3` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "status.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.status = "delete"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "status.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing all test4` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "status",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
include_status: ["init", "delete"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "status matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "status.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.status = "init"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "status.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing all test1` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "status.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.status = "step 1"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "status.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing all test2` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "status.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.status = "remove"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "status.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing all test3` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on test3` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "status.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.status = "delete"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "status.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) status (${t.status}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing all test4` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "status",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
exclude_status: ["init", "delete"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "status non matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|
package/tests/top_one.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "test_all.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
|
|
9
|
+
t.process = t.process.bind(t)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
process(callback) {
|
|
13
|
+
let t = this, fname = "test_all.test1.process"
|
|
14
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
15
|
+
callback({ success: { msg: `processing all test1` } })
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var tst2 = class test2 {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
let t = this, fname = "test_all.test2.constructor"
|
|
22
|
+
t.log = props.log
|
|
23
|
+
t.id = props.id
|
|
24
|
+
|
|
25
|
+
t.process = t.process.bind(t)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
process(callback) {
|
|
29
|
+
let t = this, fname = "test_all.test2.process"
|
|
30
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
callback({ success: { msg: `processing all test2` } })
|
|
33
|
+
}, 4000)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var tst3 = class test3 {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
let t = this, fname = "test_all.test3.constructor"
|
|
40
|
+
t.log = props.log
|
|
41
|
+
t.id = props.id
|
|
42
|
+
|
|
43
|
+
t.process = t.process.bind(t)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
process(callback) {
|
|
47
|
+
let t = this, fname = "test_all.test3.process"
|
|
48
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
49
|
+
// callback({success: { msg: `processing all test3` }})
|
|
50
|
+
callback({ error: { msg: `there is some problem thrown here on test3` } })
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var tst4 = class test4 {
|
|
55
|
+
constructor(props) {
|
|
56
|
+
let t = this, fname = "test_all.test4.constructor"
|
|
57
|
+
t.log = props.log
|
|
58
|
+
t.id = props.id
|
|
59
|
+
|
|
60
|
+
t.process = t.process.bind(t)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
process(callback) {
|
|
64
|
+
let t = this, fname = "test_all.test4.process"
|
|
65
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
66
|
+
callback({ success: { msg: `processing all test4` } })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var qObj = new queue()
|
|
71
|
+
|
|
72
|
+
qObj.init().process({
|
|
73
|
+
appender: "top_one",
|
|
74
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
75
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
76
|
+
}).then((success) => {
|
|
77
|
+
qObj.logMsg({ msg: `test success: {msg: "top_one object processed with no errors"}`.success.italic.bold, type: "success" })
|
|
78
|
+
}, (error) => {
|
|
79
|
+
if (typeof error == "string") {
|
|
80
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
81
|
+
} else {
|
|
82
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
83
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
84
|
+
}
|
|
85
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "version_matching.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.version = "2.00"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "version_matching.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "version_matching.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.version = "1.00"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "version_matching.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "version_matching.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.version = "1.00"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "version_matching.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "version_matching.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.version = "3.00"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "version_matching.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "version",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
include_version: ["1.00", "3.00"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "version_matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var queue = require("../app.js")
|
|
2
|
+
|
|
3
|
+
var tst1 = class test1 {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
let t = this, fname = "version_non_matching.test1.constructor"
|
|
6
|
+
t.log = props.log
|
|
7
|
+
t.id = props.id
|
|
8
|
+
t.version = "2.00"
|
|
9
|
+
|
|
10
|
+
t.process = t.process.bind(t)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
process(callback) {
|
|
14
|
+
let t = this, fname = "version_non_matching.test1.process"
|
|
15
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
16
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var tst2 = class test2 {
|
|
21
|
+
constructor(props) {
|
|
22
|
+
let t = this, fname = "version_non_matching.test2.constructor"
|
|
23
|
+
t.log = props.log
|
|
24
|
+
t.id = props.id
|
|
25
|
+
t.version = "1.00"
|
|
26
|
+
|
|
27
|
+
t.process = t.process.bind(t)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
process(callback) {
|
|
31
|
+
let t = this, fname = "version_non_matching.test2.process"
|
|
32
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
35
|
+
}, 4000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
var tst3 = class test3 {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
let t = this, fname = "version_non_matching.test3.constructor"
|
|
42
|
+
t.log = props.log
|
|
43
|
+
t.id = props.id
|
|
44
|
+
t.version = "1.00"
|
|
45
|
+
|
|
46
|
+
t.process = t.process.bind(t)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
process(callback) {
|
|
50
|
+
let t = this, fname = "version_non_matching.test3.process"
|
|
51
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
52
|
+
// callback({success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` }})
|
|
53
|
+
callback({ error: { msg: `there is some problem thrown here on ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var tst4 = class test4 {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
let t = this, fname = "version_non_matching.test4.constructor"
|
|
60
|
+
t.log = props.log
|
|
61
|
+
t.id = props.id
|
|
62
|
+
t.version = "3.00"
|
|
63
|
+
|
|
64
|
+
t.process = t.process.bind(t)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process(callback) {
|
|
68
|
+
let t = this, fname = "version_non_matching.test4.process"
|
|
69
|
+
t.log({ msg: `This object (${fname}) is id (${t.id}) version (${t.version}). Do stuff here`.bgBrightGreen, type: "info" })
|
|
70
|
+
callback({ success: { msg: `processing ${fname}) is id (${t.id}) version (${t.version})` } })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var qObj = new queue()
|
|
75
|
+
|
|
76
|
+
qObj.init().process({
|
|
77
|
+
appender: "version",
|
|
78
|
+
exclude_logMsg: ["debug"], /* example ["debug", "info"] */
|
|
79
|
+
exclude_version: ["1.00", "3.00"],
|
|
80
|
+
process_objects: [tst1, tst2, tst3, tst4]
|
|
81
|
+
}).then((success) => {
|
|
82
|
+
qObj.logMsg({ msg: `test success: {msg: "version non matching objects processed with no errors"}`.success.italic.bold, type: "success" })
|
|
83
|
+
}, (error) => {
|
|
84
|
+
if (typeof error == "string") {
|
|
85
|
+
qObj.logMsg({ msg: `error: ${error}`.error.italic.bold, type: "error" })
|
|
86
|
+
} else {
|
|
87
|
+
let add_s = (error.error_count > 1) ? 's' : ''
|
|
88
|
+
qObj.logMsg({ msg: `${error.error_count} error${add_s} detected`.error.italic.bold, type: "error" })
|
|
89
|
+
}
|
|
90
|
+
})
|
package/base_queue/app.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* @author Jim Manton: jrman@risebroadband.net
|
|
4
|
-
* @since 2023-02-02
|
|
5
|
-
* apps.js
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
let cc = require("colors"),
|
|
9
|
-
file_requre_data = [
|
|
10
|
-
{ props: { id: 100, name: "all", path: "./lib/appenders/all.js", absolute_path: __filename, check: true } }
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
cc.setTheme({
|
|
14
|
-
silly: 'rainbow',
|
|
15
|
-
input: 'grey',
|
|
16
|
-
verbose: 'cyan',
|
|
17
|
-
prompt: 'grey',
|
|
18
|
-
info: 'green',
|
|
19
|
-
data: 'grey',
|
|
20
|
-
help: 'cyan',
|
|
21
|
-
warn: 'yellow',
|
|
22
|
-
debug: 'blue',
|
|
23
|
-
error: 'red'
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class process_object {
|
|
28
|
-
constructor(props) {
|
|
29
|
-
let t = this
|
|
30
|
-
t.parent = props.parent
|
|
31
|
-
t.status = 'process'
|
|
32
|
-
t.objs = t.parent.getParent().getObjs()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
process() {
|
|
36
|
-
let t = this
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
continueProcessing() {
|
|
40
|
-
let t = this
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
getStatus() {
|
|
44
|
-
return this.status
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setStatus(v) {
|
|
48
|
-
this.status = v
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
exports = module.exports = class BaseQueue {
|
|
53
|
-
constructor(props = {}) {
|
|
54
|
-
let t = this, fname = `BaseQueue app constructor`
|
|
55
|
-
try {
|
|
56
|
-
t.parent = null
|
|
57
|
-
t.appenders_dir = './appenders/'
|
|
58
|
-
t.appender = null
|
|
59
|
-
|
|
60
|
-
t.logMsg = t.logMsg.bind(t)
|
|
61
|
-
t.init = t.init.bind(t)
|
|
62
|
-
t.load = t.load.bind(t)
|
|
63
|
-
t.process = t.process.bind(t)
|
|
64
|
-
t.set_base_promise = t.set_base_promise.bind(t)
|
|
65
|
-
t.base_promise = null
|
|
66
|
-
t.base_resolve = null
|
|
67
|
-
t.base_reject = null
|
|
68
|
-
|
|
69
|
-
t.set_base_promise()
|
|
70
|
-
|
|
71
|
-
return t
|
|
72
|
-
} catch (e) {
|
|
73
|
-
t.logMsg(`${fname}: ${e.message}`.error)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
set_base_promise() {
|
|
78
|
-
let t = this, fname = `BaseQueue set_base_promise`
|
|
79
|
-
|
|
80
|
-
t.base_promise = new Promise((resolve, reject) => {
|
|
81
|
-
t.base_resolve = resolve
|
|
82
|
-
t.base_reject = reject
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
t.base_promise.then(function (success) {
|
|
86
|
-
t.parent.app_resolve(success)
|
|
87
|
-
}).catch(function (err) {
|
|
88
|
-
t.parent.app_reject(err)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
init(props = {}) {
|
|
94
|
-
let t = this, fname = `BaseQueue init`
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
load(props = {}) {
|
|
98
|
-
let t = this, fname = `BaseQueue load`, a, app, req
|
|
99
|
-
|
|
100
|
-
if (typeof props.parent == 'undefined')
|
|
101
|
-
t.base_reject(`${fname}: props.parent not defined`)
|
|
102
|
-
|
|
103
|
-
t.parent = props.parent
|
|
104
|
-
props.parent = t
|
|
105
|
-
app = props.appender
|
|
106
|
-
a = t.appenders_dir + app + '.js'
|
|
107
|
-
req = require(a)
|
|
108
|
-
t.parent.logMsg(`${fname} loading appender(${a})`.debug)
|
|
109
|
-
t.appender = new req(props)
|
|
110
|
-
return t
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
process() {
|
|
114
|
-
let t = this, fname = `BaseQueue process`, res, error_count = 0
|
|
115
|
-
try {
|
|
116
|
-
t.logMsg(`${fname}`.debug)
|
|
117
|
-
|
|
118
|
-
res = t.appender.init().process().get_results_array()
|
|
119
|
-
res.map((json, i) => {
|
|
120
|
-
if (typeof json.success != "undefined")
|
|
121
|
-
t.logMsg(`${JSON.stringify(json)}`.success)
|
|
122
|
-
if (typeof json.error != "undefined") {
|
|
123
|
-
t.logMsg(`${JSON.stringify(json)}`.error)
|
|
124
|
-
error_count++
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
if (error_count) {
|
|
128
|
-
res.error_count = error_count
|
|
129
|
-
t.base_reject(res)
|
|
130
|
-
} else
|
|
131
|
-
t.base_resolve(res)
|
|
132
|
-
} catch (e) {
|
|
133
|
-
t.base_reject(`${fname}: ${e.message}.`)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
logMsg(msg, props = {}) {
|
|
138
|
-
let t = this
|
|
139
|
-
try {
|
|
140
|
-
console.log(msg)
|
|
141
|
-
return t
|
|
142
|
-
} catch (e) {
|
|
143
|
-
t.base_reject(`BaseQueue log: ${e.message} for message (${msg})`)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @author Jim Manton: jrman@risebroadband.net
|
|
3
|
-
* @since 2023-02-03
|
|
4
|
-
* base.js
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
exports = module.exports = class base {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
let t = this, fname = `base appenders constructor`
|
|
10
|
-
try {
|
|
11
|
-
t.parent = props.parent
|
|
12
|
-
t.parent.logMsg(`${fname}`.debug)
|
|
13
|
-
t.class_obj_array = []
|
|
14
|
-
t.data_to_process_array = []
|
|
15
|
-
t.objects_to_process = []
|
|
16
|
-
t.results_array = []
|
|
17
|
-
t.base_name_appender = ''
|
|
18
|
-
|
|
19
|
-
if (typeof props.data_to_process_array == 'undefined')
|
|
20
|
-
throw new Error(`props.data_to_process_array not defined`)
|
|
21
|
-
|
|
22
|
-
if (typeof props.process_objects == 'undefined')
|
|
23
|
-
throw new Error(`props.process_objects not defined`)
|
|
24
|
-
|
|
25
|
-
if (typeof props.appender == 'undefined')
|
|
26
|
-
throw new Error(`appender not defined)`)
|
|
27
|
-
|
|
28
|
-
t.base_name_appender = props.appender
|
|
29
|
-
t.data_to_process_array = props.data_to_process_array
|
|
30
|
-
t.objects_to_process = props.process_objects
|
|
31
|
-
|
|
32
|
-
t.init = t.init.bind(t)
|
|
33
|
-
t.get_objects_to_process = t.get_objects_to_process.bind(t)
|
|
34
|
-
t.get_data_to_process_array = t.get_data_to_process_array.bind(t)
|
|
35
|
-
t.process = t.process.bind(t)
|
|
36
|
-
t.get_results_array = t.get_results_array.bind(t)
|
|
37
|
-
|
|
38
|
-
return t
|
|
39
|
-
} catch (e) {
|
|
40
|
-
t.parent.base_reject(`${fname} error: ${e.message})`)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
process (props = {}) {
|
|
45
|
-
var t = this, fname = `base.process`
|
|
46
|
-
try {
|
|
47
|
-
t.parent.logMsg(`${fname}`.debug)
|
|
48
|
-
|
|
49
|
-
return t
|
|
50
|
-
} catch (e) {
|
|
51
|
-
t.parent.base_reject(`${fname} error: ${e.message})`)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get_results_array () {
|
|
56
|
-
return this.results_array
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get_data_to_process_array () {
|
|
60
|
-
return this.data_to_process_array
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get_objects_to_process () {
|
|
64
|
-
return this.objects_to_process
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
init (props = {}) {
|
|
68
|
-
var t = this, fname = `base.init`
|
|
69
|
-
try {
|
|
70
|
-
|
|
71
|
-
t.parent.logMsg(`${fname}`.debug)
|
|
72
|
-
return t
|
|
73
|
-
} catch (e) {
|
|
74
|
-
t.parent.base_reject(`${fname} error: ${e.message})`)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|