@things-factory/shell 4.1.6 → 4.1.14
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/dist-server/pubsub.js +16 -3
- package/dist-server/pubsub.js.map +1 -1
- package/package.json +7 -6
- package/server/pubsub.ts +26 -9
package/dist-server/pubsub.js
CHANGED
@@ -38,6 +38,21 @@ switch (middleware) {
|
|
38
38
|
subscriber: cluster
|
39
39
|
});
|
40
40
|
break;
|
41
|
+
case 'kafka':
|
42
|
+
try {
|
43
|
+
/*
|
44
|
+
* https://github.com/hatiolab/things-factory/issues/1239
|
45
|
+
*/
|
46
|
+
const { KafkaPubSub } = require('graphql-kafka-subscriptions');
|
47
|
+
exports.pubsub = pubsub = new KafkaPubSub(Object.assign({ topic,
|
48
|
+
host,
|
49
|
+
port }, options));
|
50
|
+
}
|
51
|
+
catch (e) {
|
52
|
+
console.error('graphql-kafka-subscriptions module is not installed, so application can not go further.');
|
53
|
+
throw e;
|
54
|
+
}
|
55
|
+
break;
|
41
56
|
default:
|
42
57
|
exports.pubsub = pubsub = new graphql_subscriptions_1.PubSub();
|
43
58
|
break;
|
@@ -53,9 +68,7 @@ const exitHandler = async (evt) => {
|
|
53
68
|
console.error(err);
|
54
69
|
}
|
55
70
|
}
|
56
|
-
|
57
|
-
if (evt.exit)
|
58
|
-
process.exit();
|
71
|
+
process.exit();
|
59
72
|
};
|
60
73
|
/*
|
61
74
|
* exit events hint from https://stackoverflow.com/a/14032965/14539284
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pubsub.js","sourceRoot":"","sources":["../server/pubsub.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAuD;AACvD,6EAAyD;AACzD,iEAA8C;AAC9C,sDAA2B;AAC3B,+BAA8B;AAE9B,6CAA4C;AAE5C,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAM,CAAC,G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AE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAE5E,oDAAoD;AACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC9E,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAE9E,6BAA6B;AAC7B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.14",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -50,10 +50,10 @@
|
|
50
50
|
"@operato/layout": "^0.3.28",
|
51
51
|
"@operato/shell": "^0.3.28",
|
52
52
|
"@operato/utils": "^0.3.28",
|
53
|
-
"@things-factory/ejs-remote": "^4.1.
|
54
|
-
"@things-factory/env": "^4.1.
|
55
|
-
"@things-factory/styles": "^4.1.
|
56
|
-
"@things-factory/utils": "^4.1.
|
53
|
+
"@things-factory/ejs-remote": "^4.1.14",
|
54
|
+
"@things-factory/env": "^4.1.14",
|
55
|
+
"@things-factory/styles": "^4.1.14",
|
56
|
+
"@things-factory/utils": "^4.1.14",
|
57
57
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
58
58
|
"@webpack-contrib/schema-utils": "^1.0.0-beta.0",
|
59
59
|
"apollo-server-core": "^3.5.0",
|
@@ -120,6 +120,7 @@
|
|
120
120
|
"optionalDependencies": {
|
121
121
|
"better-sqlite3": "^7.1.2",
|
122
122
|
"mssql": "^6.1.0",
|
123
|
+
"mysql2": "^2.3.3",
|
123
124
|
"oracledb": "^5.1.0",
|
124
125
|
"pg": "^8.3.0",
|
125
126
|
"sqlite3": "^5.0.0"
|
@@ -127,5 +128,5 @@
|
|
127
128
|
"resolutions": {
|
128
129
|
"core-js": "^3.16.0"
|
129
130
|
},
|
130
|
-
"gitHead": "
|
131
|
+
"gitHead": "15bbbacf728bbd3945ba9f757ef7af09db5241df"
|
131
132
|
}
|
package/server/pubsub.ts
CHANGED
@@ -43,6 +43,23 @@ switch (middleware) {
|
|
43
43
|
subscriber: cluster
|
44
44
|
})
|
45
45
|
break
|
46
|
+
case 'kafka':
|
47
|
+
try {
|
48
|
+
/*
|
49
|
+
* https://github.com/hatiolab/things-factory/issues/1239
|
50
|
+
*/
|
51
|
+
const { KafkaPubSub } = require('graphql-kafka-subscriptions')
|
52
|
+
pubsub = new KafkaPubSub({
|
53
|
+
topic,
|
54
|
+
host,
|
55
|
+
port,
|
56
|
+
...options
|
57
|
+
})
|
58
|
+
} catch (e) {
|
59
|
+
console.error('graphql-kafka-subscriptions module is not installed, so application can not go further.')
|
60
|
+
throw e
|
61
|
+
}
|
62
|
+
break
|
46
63
|
default:
|
47
64
|
pubsub = new PubSub()
|
48
65
|
break
|
@@ -51,7 +68,7 @@ switch (middleware) {
|
|
51
68
|
debug(middleware || 'default', 'pubsub initialized.')
|
52
69
|
|
53
70
|
// kafka pubsub keeps connection and app port with 'ctrl+c' termination.
|
54
|
-
const exitHandler = async
|
71
|
+
const exitHandler = async evt => {
|
55
72
|
if (pubsub.close) {
|
56
73
|
try {
|
57
74
|
await pubsub.close()
|
@@ -59,25 +76,25 @@ const exitHandler = async (evt) => {
|
|
59
76
|
console.error(err)
|
60
77
|
}
|
61
78
|
}
|
62
|
-
|
63
|
-
|
79
|
+
|
80
|
+
process.exit()
|
64
81
|
}
|
65
82
|
|
66
|
-
/*
|
83
|
+
/*
|
67
84
|
* exit events hint from https://stackoverflow.com/a/14032965/14539284
|
68
85
|
*/
|
69
86
|
|
70
87
|
//do something when app is closing
|
71
|
-
process.on('exit', exitHandler.bind(null, { name: 'exit', exit: true }
|
88
|
+
process.on('exit', exitHandler.bind(null, { name: 'exit', exit: true }))
|
72
89
|
|
73
90
|
//catches ctrl+c event
|
74
|
-
process.on('SIGINT', exitHandler.bind(null, { name: 'SIGINT', exit: true }
|
91
|
+
process.on('SIGINT', exitHandler.bind(null, { name: 'SIGINT', exit: true }))
|
75
92
|
|
76
93
|
// catches "kill pid" (for example: nodemon restart)
|
77
|
-
process.on('SIGUSR1', exitHandler.bind(null, { name: 'SIGUSR1', exit: true }
|
78
|
-
process.on('SIGUSR2', exitHandler.bind(null, { name: 'SIGUSR2', exit: true }
|
94
|
+
process.on('SIGUSR1', exitHandler.bind(null, { name: 'SIGUSR1', exit: true }))
|
95
|
+
process.on('SIGUSR2', exitHandler.bind(null, { name: 'SIGUSR2', exit: true }))
|
79
96
|
|
80
97
|
//catches uncaught exceptions
|
81
|
-
process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }
|
98
|
+
process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }))
|
82
99
|
|
83
100
|
export { pubsub }
|