@rpcbase/server 0.153.0 → 0.155.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/cli/run_docker.js +2 -2
- package/express/index.js +1 -0
- package/package.json +2 -2
- package/queue/register_queue_listener.js +21 -14
package/cli/run_docker.js
CHANGED
|
@@ -25,10 +25,10 @@ const run_docker = async(infrastructure_dir, proj_prefix) => {
|
|
|
25
25
|
compose_files.push("-f", "dev.yml")
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const opts = ["--build", "--remove-orphans"]
|
|
28
|
+
const opts = ["--build", "--quiet-pull", "--remove-orphans", "--force-recreate"]
|
|
29
29
|
if (!is_production) opts.push("--abort-on-container-exit")
|
|
30
30
|
|
|
31
|
-
const cmd = "docker
|
|
31
|
+
const cmd = "docker compose"
|
|
32
32
|
const cmd_args = ["--env-file", env_path, "-p", proj_prefix, ...compose_files, "up", ...opts]
|
|
33
33
|
|
|
34
34
|
console.log(cmd_args.join(" "))
|
package/express/index.js
CHANGED
|
@@ -57,6 +57,7 @@ module.exports = () => {
|
|
|
57
57
|
`http://admin.localhost:${CLIENT_PORT}`,
|
|
58
58
|
// TODO: WARNING: TMP hardcoded port
|
|
59
59
|
"http://localhost:8090", // TMP: used by inspected app from admin
|
|
60
|
+
"http://localhost:8091", // TMP: used by inspected app from admin
|
|
60
61
|
"http://localhost:9292", // TMP
|
|
61
62
|
]
|
|
62
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.155.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@rpcbase/agent": "0.
|
|
13
|
+
"@rpcbase/agent": "0.26.0",
|
|
14
14
|
"@rpcbase/std": "0.5.0",
|
|
15
15
|
"body-parser": "1.20.1",
|
|
16
16
|
"bull": "4.10.2",
|
|
@@ -7,8 +7,6 @@ const queue = require("./index")
|
|
|
7
7
|
const dispatch_queue = require("./dispatch_queue")
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
console.log("AFTER REQUIRE register_model_emitter")
|
|
11
|
-
|
|
12
10
|
const log = debug("rb:queue:listener")
|
|
13
11
|
|
|
14
12
|
// Listens for mongodb change events,
|
|
@@ -31,8 +29,18 @@ const mongoose_delete_plugin = (schema) => {
|
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
const get_dispatch_change_handler = (model_name) => (change) => {
|
|
35
|
-
|
|
32
|
+
const get_dispatch_change_handler = (model_name, filter_fn) => (change) => {
|
|
33
|
+
if (typeof filter_fn === "function") {
|
|
34
|
+
let ret
|
|
35
|
+
try {
|
|
36
|
+
ret = filter_fn(model_name, change)
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.log("get_dispatch_change_handler::filter_fn::error:", err)
|
|
39
|
+
}
|
|
40
|
+
if (!ret) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
const op = change.operationType
|
|
37
45
|
if (["insert", "update"].includes(op)) {
|
|
38
46
|
dispatch_queue(queue, model_name, op, change.fullDocument)
|
|
@@ -40,15 +48,15 @@ const get_dispatch_change_handler = (model_name) => (change) => {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
|
|
43
|
-
const register_model_emitter = (model_name) => {
|
|
44
|
-
|
|
51
|
+
const register_model_emitter = (model_name, filter_fn) => {
|
|
52
|
+
log("registering emitter for", model_name)
|
|
45
53
|
const model = mongoose.model(model_name)
|
|
46
54
|
// TODO: implement delete operation fullDocument retrieve,
|
|
47
55
|
// when this is released https://jira.mongodb.org/browse/SERVER-36941
|
|
48
56
|
// this is done via a plugin right now
|
|
49
57
|
const emitter = model.watch({fullDocument: "updateLookup"})
|
|
50
58
|
|
|
51
|
-
emitter.on("change", get_dispatch_change_handler(model_name))
|
|
59
|
+
emitter.on("change", get_dispatch_change_handler(model_name, filter_fn))
|
|
52
60
|
|
|
53
61
|
emitter.on("error", (err) => {
|
|
54
62
|
log("server::queue::register_queue_listener:: change listener emitter got error", err)
|
|
@@ -56,24 +64,23 @@ const register_model_emitter = (model_name) => {
|
|
|
56
64
|
|
|
57
65
|
emitter.on("close", (arg, arg2) => {
|
|
58
66
|
// TODO: add exponential backoff retry
|
|
59
|
-
console.log("queue_listener: emitter closed, model:", model_name, "retrying on next
|
|
67
|
+
console.log("queue_listener: emitter closed, model:", model_name, "retrying on next tick6663")
|
|
60
68
|
process.nextTick(() => {
|
|
61
|
-
register_model_emitter(model_name)
|
|
69
|
+
register_model_emitter(model_name, filter_fn)
|
|
62
70
|
})
|
|
63
71
|
})
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
|
|
67
|
-
const register_queue_listener = () => {
|
|
75
|
+
const register_queue_listener = (filter_fn) => {
|
|
68
76
|
// register the mongoose delete plugin
|
|
69
77
|
log("registering mongoose_delete_plugin")
|
|
70
78
|
mongoose.plugin(mongoose_delete_plugin)
|
|
71
79
|
|
|
72
|
-
mongoose.connection.
|
|
73
|
-
|
|
80
|
+
mongoose.connection.once("open", () => {
|
|
81
|
+
log("queue_listener mongoose connection opened")
|
|
74
82
|
const models = mongoose.modelNames()
|
|
75
|
-
|
|
76
|
-
models.forEach(register_model_emitter)
|
|
83
|
+
models.forEach((model_name) => register_model_emitter(model_name, filter_fn))
|
|
77
84
|
})
|
|
78
85
|
}
|
|
79
86
|
|