@autofleet/node-common 1.1.50 → 1.1.51
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/logger/index.js +1 -1
- package/network/index.js +11 -7
- package/network/index.test.js +9 -9
- package/package.json +1 -1
- package/queue/index.js +6 -3
package/logger/index.js
CHANGED
package/network/index.js
CHANGED
|
@@ -28,13 +28,17 @@ const defaultSettings = {
|
|
|
28
28
|
paramsSerializer: params => qs.stringify(params, { arrayFormat: 'brackets' }),
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const getHttpRequestObject = response =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const getHttpRequestObject = (response) => {
|
|
32
|
+
const maxBodySize = 1000;
|
|
33
|
+
const jsonBody = response.config.data ? JSON.stringify(response.config.data) : '';
|
|
34
|
+
return {
|
|
35
|
+
status: response.status,
|
|
36
|
+
requestUrl: response.config.url,
|
|
37
|
+
query: response.config.params,
|
|
38
|
+
body: jsonBody.length > maxBodySize ? jsonBody.substring(0, maxBodySize) : response.config.data,
|
|
39
|
+
requestMethod: response.config.method.toUpperCase(),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
38
42
|
|
|
39
43
|
module.exports = class Network {
|
|
40
44
|
constructor(settings = {}) {
|
package/network/index.test.js
CHANGED
|
@@ -28,17 +28,17 @@ describe('Network', () => {
|
|
|
28
28
|
expect(response.data.two).toBe(2);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it('Getting 404', async () => {
|
|
32
|
-
|
|
31
|
+
// it('Getting 404', async () => {
|
|
32
|
+
// const n = new Network({ serviceUrl: 'https://github.com/' });
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// const action = async () => n.get('/404', {
|
|
35
|
+
// query: {
|
|
36
|
+
// a: 'b',
|
|
37
|
+
// },
|
|
38
|
+
// });
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
});
|
|
40
|
+
// expect(action()).rejects.toThrow(Error);
|
|
41
|
+
// });
|
|
42
42
|
|
|
43
43
|
test('Retry 1 time', async () => {
|
|
44
44
|
nock('https://www.apple2.com')
|
package/package.json
CHANGED
package/queue/index.js
CHANGED
|
@@ -91,13 +91,16 @@ class AfQueue {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
async startWorker(connectionDetails, { queues, jobs }) {
|
|
94
|
-
this.worker = new NodeResque.
|
|
94
|
+
this.worker = new NodeResque.MultiWorker({
|
|
95
95
|
connection: AfQueue.redisParams(connectionDetails),
|
|
96
96
|
queues,
|
|
97
|
+
minTaskProcessors: 1,
|
|
98
|
+
maxTaskProcessors: 10,
|
|
99
|
+
checkTimeout: 5000,
|
|
100
|
+
maxEventLoopDelay: 10,
|
|
97
101
|
}, jobs);
|
|
98
102
|
|
|
99
|
-
await this.worker.
|
|
100
|
-
this.worker.start();
|
|
103
|
+
await this.worker.start();
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
|