@rpcbase/server 0.131.0 → 0.132.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
CHANGED
package/queue/dispatch_queue.js
CHANGED
|
@@ -30,19 +30,21 @@ const mongoose_delete_plugin = (schema) => {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const handle_change = (data) => {
|
|
34
|
+
console.log("le change data", data)
|
|
35
|
+
const collection = data.ns.coll
|
|
36
|
+
const op = data.operationType
|
|
35
37
|
if (["insert", "update"].includes(op)) {
|
|
36
|
-
dispatch_queue(queue,
|
|
38
|
+
dispatch_queue(queue, collection, op, change.fullDocument)
|
|
37
39
|
}
|
|
38
40
|
// else
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
const register_model_emitter = (model_name) => {
|
|
43
|
-
console.log("REGGGGGG", model_name)
|
|
44
|
-
const estack = new Error()
|
|
45
|
-
console.log("stack", estack.stack)
|
|
45
|
+
// console.log("REGGGGGG", model_name)
|
|
46
|
+
// const estack = new Error()
|
|
47
|
+
// console.log("stack", estack.stack)
|
|
46
48
|
|
|
47
49
|
const model = mongoose.model(model_name)
|
|
48
50
|
|
|
@@ -68,18 +70,32 @@ const register_model_emitter = (model_name) => {
|
|
|
68
70
|
})
|
|
69
71
|
}
|
|
70
72
|
|
|
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
|
+
}
|
|
71
85
|
|
|
72
|
-
const register_queue_listener = async() => {
|
|
73
|
-
mongoose.connection.once("open", () => {
|
|
74
|
-
console.log("CONNEC OPEN:register_queue_listener")
|
|
75
|
-
// register the mongoose delete plugin
|
|
76
|
-
mongoose.plugin(mongoose_delete_plugin)
|
|
77
86
|
|
|
78
|
-
const models = mongoose.modelNames()
|
|
79
87
|
|
|
80
|
-
|
|
88
|
+
const register_queue_listener = () => {
|
|
89
|
+
// register the mongoose delete plugin
|
|
90
|
+
log("registering mongoose_delete_plugin")
|
|
91
|
+
mongoose.plugin(mongoose_delete_plugin)
|
|
81
92
|
|
|
82
|
-
|
|
93
|
+
mongoose.connection.on("open", () => {
|
|
94
|
+
register_emitter()
|
|
95
|
+
// console.log("CONNEC OPEN:register_queue_listener")
|
|
96
|
+
// // const models = mongoose.modelNames()
|
|
97
|
+
// console.log("WILL register_model_emitter")
|
|
98
|
+
// models.forEach(register_model_emitter)
|
|
83
99
|
})
|
|
84
100
|
}
|
|
85
101
|
|