soajs.controller 4.2.9 → 4.2.11
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/mw/awareness/ha.js +1 -3
- package/mw/cors/index.js +1 -0
- package/mw/gotoService/lib/preRedirect.js +10 -10
- package/package.json +1 -1
- package/server/controller.js +1 -1
package/mw/awareness/ha.js
CHANGED
|
@@ -111,8 +111,6 @@ let lib = {
|
|
|
111
111
|
if (error) {
|
|
112
112
|
if (error.message) {
|
|
113
113
|
param.log.error(error.message);
|
|
114
|
-
} else {
|
|
115
|
-
param.log.error(error);
|
|
116
114
|
}
|
|
117
115
|
return cb(null);
|
|
118
116
|
}
|
|
@@ -178,7 +176,7 @@ let lib = {
|
|
|
178
176
|
}, function () {
|
|
179
177
|
awarenessCache = myCache;
|
|
180
178
|
param.log.debug("Awareness cache rebuilt successfully");
|
|
181
|
-
param.log.debug(awarenessCache);
|
|
179
|
+
param.log.debug(JSON.stringify(awarenessCache));
|
|
182
180
|
|
|
183
181
|
let cacheTTL = registryModule.get().serviceConfig.awareness.cacheTTL;
|
|
184
182
|
if (cacheTTL) {
|
package/mw/cors/index.js
CHANGED
|
@@ -28,6 +28,7 @@ module.exports = () => {
|
|
|
28
28
|
res.setHeader('Access-Control-Allow-Methods', methods);
|
|
29
29
|
res.setHeader('Access-Control-Allow-Headers', headers);
|
|
30
30
|
res.setHeader('Access-Control-Max-Age', maxage);
|
|
31
|
+
res.setHeader('Access-Control-Expose-Headers', headers);
|
|
31
32
|
|
|
32
33
|
res.statusCode = 204;
|
|
33
34
|
res.end();
|
|
@@ -22,38 +22,38 @@ const request = require('request');
|
|
|
22
22
|
module.exports = (req, res, core, cb) => {
|
|
23
23
|
let restServiceParams = req.soajs.controller.serviceParams;
|
|
24
24
|
let restServiceParams_msg = '[' + restServiceParams.name + (restServiceParams.version ? ('@' + restServiceParams.version) : '') + ']';
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
let config = req.soajs.registry.services.controller;
|
|
27
27
|
if (!config) {
|
|
28
28
|
return req.soajs.controllerResponse(core.error.getError(131));
|
|
29
29
|
}
|
|
30
30
|
let nextStep = function (host, port, fullURI) {
|
|
31
|
-
req.soajs.log.info({
|
|
31
|
+
req.soajs.log.info(JSON.stringify({
|
|
32
32
|
"serviceName": restServiceParams.name,
|
|
33
33
|
"host": host,
|
|
34
34
|
"version": restServiceParams.version,
|
|
35
35
|
"url": restServiceParams.url,
|
|
36
36
|
"port": restServiceParams.registry.port,
|
|
37
37
|
"header": req.headers
|
|
38
|
-
});
|
|
39
|
-
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
40
|
let requestTOR = restServiceParams.registry.requestTimeoutRenewal || config.requestTimeoutRenewal;
|
|
41
41
|
let requestTO = restServiceParams.registry.requestTimeout || config.requestTimeout;
|
|
42
42
|
let timeToRenew = requestTO * 100;
|
|
43
43
|
req.soajs.controller.renewalCount = 0;
|
|
44
44
|
req.soajs.controller.monitorEndingReq = false;
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
let isStream = false;
|
|
47
47
|
let renewReqMonitor = function () {
|
|
48
48
|
if (!isStream) {
|
|
49
49
|
req.soajs.log.warn(restServiceParams_msg + ' - Request is taking too much time ...');
|
|
50
50
|
req.soajs.controller.renewalCount++;
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
if (req.soajs.controller.renewalCount < requestTOR) {
|
|
53
53
|
req.soajs.log.info(' - Trying to keep request alive by checking the service heartbeat ... ' + req.soajs.controller.renewalCount);
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
let uri = 'http://' + host + ':' + (restServiceParams.registry.port + req.soajs.registry.serviceConfig.ports.maintenanceInc) + '/heartbeat';
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
if (restServiceParams.registry.maintenance && restServiceParams.registry.maintenance.readiness && restServiceParams.registry.maintenance.port) {
|
|
58
58
|
let maintenancePort = port;
|
|
59
59
|
let path = restServiceParams.registry.maintenance.readiness;
|
|
@@ -117,7 +117,7 @@ module.exports = (req, res, core, cb) => {
|
|
|
117
117
|
} else {
|
|
118
118
|
res.setTimeout(timeToRenew, renewReqMonitor);
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
return cb({
|
|
122
122
|
'host': host,
|
|
123
123
|
'config': config,
|
|
@@ -125,7 +125,7 @@ module.exports = (req, res, core, cb) => {
|
|
|
125
125
|
'uri': (fullURI ? host + restServiceParams.url : 'http://' + host + ':' + port + restServiceParams.url)
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
if (restServiceParams.registry && restServiceParams.registry.type === "endpoint") {
|
|
130
130
|
let host = restServiceParams.registry.src.url;
|
|
131
131
|
if (restServiceParams.version && restServiceParams.registry.src.urls) {
|
package/package.json
CHANGED
package/server/controller.js
CHANGED
|
@@ -79,12 +79,12 @@ Controller.prototype.init = function (callback) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
let app = connect();
|
|
82
|
-
app.use(favicon_mw());
|
|
83
82
|
app.use(soajs_mw({
|
|
84
83
|
"log": log,
|
|
85
84
|
"core": core
|
|
86
85
|
}));
|
|
87
86
|
app.use(cors_mw());
|
|
87
|
+
app.use(favicon_mw());
|
|
88
88
|
app.use(response_mw({ "controllerResponse": true }));
|
|
89
89
|
app.use(maintenanceMode_mw()); //NOTE: this is for global maintenance mode
|
|
90
90
|
|