@rpcbase/server 0.136.0 → 0.137.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/package.json +1 -1
- package/queue/register_queue_listener.js +15 -28
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ const queue = require("./index")
|
|
|
6
6
|
|
|
7
7
|
const dispatch_queue = require("./dispatch_queue")
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
console.log("AFTER REQUIRE register_model_emitter")
|
|
10
11
|
|
|
11
12
|
const log = debug("rb:queue:listener")
|
|
@@ -30,15 +31,15 @@ const mongoose_delete_plugin = (schema) => {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
const handle_change = (data) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
34
|
+
// const handle_change = (data) => {
|
|
35
|
+
// console.log("le change data", data)
|
|
36
|
+
// const collection = data.ns.coll
|
|
37
|
+
// const op = data.operationType
|
|
38
|
+
// if (["insert", "update"].includes(op)) {
|
|
39
|
+
// dispatch_queue(queue, collection, op, change.fullDocument)
|
|
40
|
+
// }
|
|
41
|
+
// // else
|
|
42
|
+
// }
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
const register_model_emitter = (model_name) => {
|
|
@@ -70,20 +71,6 @@ const register_model_emitter = (model_name) => {
|
|
|
70
71
|
})
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
const register_emitter = () => {
|
|
74
|
-
console.log("will register emitter wow")
|
|
75
|
-
const emitter = mongoose.connection.watch()
|
|
76
|
-
|
|
77
|
-
emitter.on("change", (data) => {
|
|
78
|
-
handle_change(data)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
emitter.on("close", () => {
|
|
82
|
-
// console.log("change emitter closed")
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
74
|
|
|
88
75
|
const register_queue_listener = () => {
|
|
89
76
|
// register the mongoose delete plugin
|
|
@@ -91,11 +78,11 @@ const register_queue_listener = () => {
|
|
|
91
78
|
mongoose.plugin(mongoose_delete_plugin)
|
|
92
79
|
|
|
93
80
|
mongoose.connection.on("open", () => {
|
|
94
|
-
register_emitter()
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
// register_emitter()
|
|
82
|
+
console.log("CONNEC OPEN:register_queue_listener")
|
|
83
|
+
// const models = mongoose.modelNames()
|
|
84
|
+
console.log("WILL register_model_emitter")
|
|
85
|
+
models.forEach(register_model_emitter)
|
|
99
86
|
})
|
|
100
87
|
}
|
|
101
88
|
|