cry-ebus2 2.2.5 → 3.0.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/dist/EbusConfiguration.d.ts +1 -0
- package/dist/EbusConfiguration.d.ts.map +1 -1
- package/dist/broker.d.ts +1 -0
- package/dist/broker.d.ts.map +1 -1
- package/dist/broker.js +38 -6
- package/dist/broker.js.map +1 -1
- package/dist/clientBlocking.js +5 -5
- package/dist/clientBlocking.js.map +1 -1
- package/dist/clientNonBlocking.d.ts +1 -0
- package/dist/clientNonBlocking.d.ts.map +1 -1
- package/dist/clientNonBlocking.js +12 -5
- package/dist/clientNonBlocking.js.map +1 -1
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +2 -1
- package/dist/consts.js.map +1 -1
- package/dist/delayWorker.js +2 -2
- package/dist/delayWorker.js.map +1 -1
- package/dist/echoWorker.js +1 -1
- package/dist/echoWorker.js.map +1 -1
- package/dist/errorWorker.js +1 -1
- package/dist/errorWorker.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loadConfiguration.js +1 -1
- package/dist/loadConfiguration.js.map +1 -1
- package/dist/pub.js +2 -2
- package/dist/pub.js.map +1 -1
- package/dist/rejectWorker.js +1 -1
- package/dist/rejectWorker.js.map +1 -1
- package/dist/run/all.js +1 -1
- package/dist/run/all.js.map +1 -1
- package/dist/run/broker.js +1 -1
- package/dist/run/broker.js.map +1 -1
- package/dist/run/call.js +3 -3
- package/dist/run/call.js.map +1 -1
- package/dist/run/calling.js +2 -2
- package/dist/run/calling.js.map +1 -1
- package/dist/run/callingBurst.js +2 -2
- package/dist/run/callingBurst.js.map +1 -1
- package/dist/run/delay.js +1 -1
- package/dist/run/delay.js.map +1 -1
- package/dist/run/echo.js +1 -1
- package/dist/run/echo.js.map +1 -1
- package/dist/run/error.js +1 -1
- package/dist/run/error.js.map +1 -1
- package/dist/run/ping.js +3 -3
- package/dist/run/ping.js.map +1 -1
- package/dist/run/pub.js +2 -2
- package/dist/run/pub.js.map +1 -1
- package/dist/run/reject.js +1 -1
- package/dist/run/reject.js.map +1 -1
- package/dist/run/sub.js +1 -1
- package/dist/run/sub.js.map +1 -1
- package/dist/run/workers.js +38 -9
- package/dist/run/workers.js.map +1 -1
- package/dist/serialize.d.ts.map +1 -1
- package/dist/serialize.js +12 -14
- package/dist/serialize.js.map +1 -1
- package/dist/sub.js +2 -2
- package/dist/sub.js.map +1 -1
- package/dist/test/config.js +3 -3
- package/dist/test/config.js.map +1 -1
- package/dist/test/echo.js +15 -21
- package/dist/test/echo.js.map +1 -1
- package/dist/test/pack.js +16 -12
- package/dist/test/pack.js.map +1 -1
- package/dist/test/performance.js +9 -9
- package/dist/test/performance.js.map +1 -1
- package/dist/test/pub.js.map +1 -1
- package/dist/test/reject.js +7 -7
- package/dist/test/reject.js.map +1 -1
- package/dist/test/services.js +9 -9
- package/dist/test/services.js.map +1 -1
- package/dist/test/stress.js +1 -1
- package/dist/test/stress.js.map +1 -1
- package/dist/test/timing.js +14 -14
- package/dist/test/timing.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +29 -23
- package/dist/worker.js.map +1 -1
- package/package.json +13 -12
- package/src/EbusConfiguration.ts +1 -0
- package/src/broker.ts +37 -2
- package/src/clientNonBlocking.ts +8 -0
- package/src/consts.ts +2 -1
- package/src/index.ts +0 -3
- package/src/run/all.ts +0 -2
- package/src/run/call.ts +1 -1
- package/src/run/ping.ts +1 -1
- package/src/run/workers.ts +47 -11
- package/src/serialize.ts +9 -10
- package/src/src/notepack.d.ts +2 -0
- package/src/test/echo.ts +15 -18
- package/src/test/pack.ts +9 -8
- package/src/test/performance.ts +13 -12
- package/src/test/pub.ts +1 -3
- package/src/types.ts +2 -0
- package/src/worker.ts +38 -24
package/src/run/workers.ts
CHANGED
|
@@ -1,14 +1,50 @@
|
|
|
1
|
-
import { DelayWorker } from "../delayWorker";
|
|
2
|
-
import { EchoWorker } from "../echoWorker";
|
|
3
|
-
import { ErrorWorker } from "../errorWorker";
|
|
4
|
-
import { RejectWorker } from "../rejectWorker";
|
|
5
1
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
import { objStrToJson } from "cry-helpers";
|
|
3
|
+
import { config } from "dotenv";
|
|
4
|
+
import { Client } from "../client";
|
|
5
|
+
import { program } from "commander"
|
|
6
|
+
import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
7
|
+
import { exit } from "process";
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
new DelayWorker().start()
|
|
12
|
-
new RejectWorker().start()
|
|
13
|
-
new ErrorWorker().start()
|
|
9
|
+
config();
|
|
14
10
|
|
|
11
|
+
program.version('0.0.2');
|
|
12
|
+
|
|
13
|
+
let client = new Client()
|
|
14
|
+
|
|
15
|
+
function exitProgram(message: string) {
|
|
16
|
+
console.error(message)
|
|
17
|
+
exit(2)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.description('calls a worker')
|
|
22
|
+
.option('-w, --workers', 'get workers (default)', true)
|
|
23
|
+
.option('-s, --services', 'get services instead of workers')
|
|
24
|
+
.option('-r, --restart <whom>', 'restart all workers')
|
|
25
|
+
.action(async (params) => {
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
|
|
29
|
+
if (program.restart) {
|
|
30
|
+
console.log(`request restart of \x1b[32m${program.restart}\x1b[0m workers`)
|
|
31
|
+
await client.restartAllWorkers(program.restart);
|
|
32
|
+
}
|
|
33
|
+
else if (program.services) {
|
|
34
|
+
let res = await client.services()
|
|
35
|
+
console.dir(res)
|
|
36
|
+
} else {
|
|
37
|
+
let res = await client.workers()
|
|
38
|
+
console.dir(res)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} catch (err: any) {
|
|
42
|
+
console.error(`\x1b[31munexpected error\x1b[0m ${err.message}`)
|
|
43
|
+
console.log(err)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
process.exit(0)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
program.parse(process.argv);
|
package/src/serialize.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
+
|
|
1
2
|
import { serialize } from "cry-helpers";
|
|
2
|
-
import {
|
|
3
|
+
import { deflateRaw, inflateRaw } from "pako";
|
|
3
4
|
import { EbusRequestOptions } from "./EbusRequestOptions";
|
|
4
|
-
|
|
5
|
+
import notepack from "notepack.io"
|
|
5
6
|
|
|
6
7
|
export function pack(data: any, opts: Partial<EbusRequestOptions>)
|
|
7
8
|
{
|
|
8
9
|
if (opts.prepacked) return data;
|
|
9
10
|
if (!opts.raw) {
|
|
10
|
-
data = serialize.
|
|
11
|
-
|
|
12
|
-
} else {
|
|
13
|
-
if (opts.zip) data = deflate( Uint8Array.from(data) )
|
|
11
|
+
data = serialize.encode(data);
|
|
12
|
+
data = notepack.encode(data);
|
|
14
13
|
}
|
|
14
|
+
if (opts.zip) data = deflateRaw(data)
|
|
15
15
|
return data
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function unpack<T>(data: any, opts: Partial<EbusRequestOptions>): T | undefined {
|
|
19
19
|
if (data === undefined) return undefined;
|
|
20
|
+
if (opts?.zip) data = inflateRaw(data)
|
|
20
21
|
if (!opts.raw) {
|
|
21
|
-
|
|
22
|
-
data = serialize.
|
|
23
|
-
} else {
|
|
24
|
-
if (opts.zip) data = Buffer.from(inflate(data))
|
|
22
|
+
data = notepack.decode(Buffer.from(data))
|
|
23
|
+
data = serialize.decode(data)
|
|
25
24
|
}
|
|
26
25
|
return data as T
|
|
27
26
|
}
|
package/src/test/echo.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
|
7
7
|
|
|
8
8
|
describe('echo', async function () {
|
|
9
9
|
|
|
10
|
-
this.timeout(
|
|
10
|
+
this.timeout(60000)
|
|
11
11
|
|
|
12
12
|
new Broker().start()
|
|
13
13
|
new EchoWorker().start()
|
|
@@ -15,14 +15,17 @@ describe('echo', async function () {
|
|
|
15
15
|
|
|
16
16
|
let client = new Client()
|
|
17
17
|
|
|
18
|
+
console.log('started');
|
|
19
|
+
|
|
20
|
+
|
|
18
21
|
it('should return passed-in object', async () => {
|
|
19
|
-
let rep = await client.request<{ delay: number }>("delay", { delay:
|
|
20
|
-
expect(rep?.delay).to.eq(
|
|
22
|
+
let rep = await client.request<{ delay: number }>("delay", { delay: 50 })
|
|
23
|
+
expect(rep?.delay).to.eq(50)
|
|
21
24
|
});
|
|
22
25
|
|
|
23
26
|
it('should return passed-in object zipped', async () => {
|
|
24
|
-
let rep = await client.request<{ delay: number }>("delay", { delay:
|
|
25
|
-
expect(rep?.delay).to.eq(
|
|
27
|
+
let rep = await client.request<{ delay: number }>("delay", { delay: 50 }, { zip: true })
|
|
28
|
+
expect(rep?.delay).to.eq(50)
|
|
26
29
|
});
|
|
27
30
|
|
|
28
31
|
|
|
@@ -35,24 +38,24 @@ describe('echo', async function () {
|
|
|
35
38
|
it('should return passed-in object raw and zipped', async () => {
|
|
36
39
|
let load = Buffer.from("ABC")
|
|
37
40
|
let rep = await client.request<{ delay: number }>("echo", load, { raw: true, zip: true })
|
|
38
|
-
expect(rep
|
|
41
|
+
expect(Buffer.from(rep as any).toString()).to.eq("ABC")
|
|
39
42
|
});
|
|
40
43
|
|
|
44
|
+
|
|
41
45
|
it('should return unpacked object', async () => {
|
|
42
46
|
let load = Buffer.from("ABC")
|
|
43
47
|
let res = (await client.requestUpacked<{ delay: number }>("echo", load, { raw: true, zip: true, })) as unknown as EbusUnpackedResult<string>
|
|
44
|
-
let rep = unpack<string>(res.data,res.opts)
|
|
45
|
-
expect(rep
|
|
48
|
+
let rep = unpack<string>(res.data, res.opts)
|
|
49
|
+
expect(Buffer.from(rep as any).toString()).to.eq("ABC")
|
|
46
50
|
});
|
|
47
51
|
|
|
48
|
-
|
|
49
52
|
it('should accept externally prepacked object', async () => {
|
|
50
53
|
let load = { a: { b: 2 } }
|
|
51
54
|
let loadPrepacked = pack(load,{ zip: true })
|
|
52
55
|
let rep = (await client.request<{ a: { b:2 } }>("echo", loadPrepacked, { prepacked:true, zip: true, receiveTimeout:30000 }))
|
|
53
56
|
expect(rep!.a.b).to.eq(2)
|
|
54
57
|
});
|
|
55
|
-
|
|
58
|
+
|
|
56
59
|
it('should accept externally prepacked object', async () => {
|
|
57
60
|
let load = { a: { b: 2 } }
|
|
58
61
|
let loadPrepacked = pack(load, { zip: true })
|
|
@@ -60,15 +63,9 @@ describe('echo', async function () {
|
|
|
60
63
|
let rep = unpack < { a: { b: 2 } }>(res.data, res.opts)
|
|
61
64
|
expect(rep!.a.b).to.eq(2)
|
|
62
65
|
});
|
|
66
|
+
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
let load = { a: { b: 2 } }
|
|
66
|
-
let loadPrepacked = pack(load, { zip: true })
|
|
67
|
-
let res = (await client.requestUpacked<{ a: { b: 2 } }>("echo", loadPrepacked, { prepacked: true, zip: true, receiveTimeout: 30000 })) as unknown as EbusUnpackedResult<{ a: { b: 2 } }>
|
|
68
|
-
let rep = unpack<{ a: { b: 2 } }>(res.data, res.opts)
|
|
69
|
-
expect(rep!.a.b).to.eq(2)
|
|
70
|
-
});
|
|
71
|
-
|
|
68
|
+
|
|
72
69
|
it('exists', () => {
|
|
73
70
|
process.exit()
|
|
74
71
|
})
|
package/src/test/pack.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
-
import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
4
3
|
import { unpack, pack } from "../index";
|
|
5
4
|
|
|
6
|
-
describe('
|
|
5
|
+
describe('pack', async function () {
|
|
7
6
|
|
|
8
7
|
let o = () => [{ o: 1, a: ["ABC"] }];
|
|
9
8
|
|
|
@@ -16,20 +15,23 @@ describe('stress', async function () {
|
|
|
16
15
|
expect(o1[0].a[0]).to.eq("ABC")
|
|
17
16
|
expect(o2[0].a[0]).to.eq("ABC")
|
|
18
17
|
});
|
|
19
|
-
|
|
20
18
|
it('should unpack serialized, unzipped', async () => {
|
|
21
|
-
let opts = {}
|
|
22
|
-
|
|
19
|
+
let opts = { zip: true }
|
|
20
|
+
let packed = pack(o(), opts)
|
|
21
|
+
let unpacked = unpack<any>(packed, opts)
|
|
22
|
+
expect(unpacked[0].a[0]).to.eq("ABC")
|
|
23
23
|
});
|
|
24
24
|
it('should unpack serialized, zipped', async () => {
|
|
25
25
|
let opts = { zip: true }
|
|
26
|
-
|
|
26
|
+
let packed = pack(o(), opts)
|
|
27
|
+
let unpacked = unpack<any>(packed, opts)
|
|
28
|
+
expect(unpacked[0].a[0]).to.eq("ABC")
|
|
27
29
|
});
|
|
28
30
|
it('should unpack serialized, zipped', async () => {
|
|
29
31
|
let opts = { zip: true, raw: true }
|
|
30
32
|
let buff1 = Buffer.from( JSON.stringify(o()) )
|
|
31
33
|
let buff2 = Buffer.from( JSON.stringify(o()) )
|
|
32
|
-
let res = unpack<any>(pack(buff1, opts), opts)
|
|
34
|
+
let res = Buffer.from(unpack<any>(pack(buff1, opts), opts))
|
|
33
35
|
expect(res.toString()).to.equal(buff2.toString())
|
|
34
36
|
});
|
|
35
37
|
it('should unpack unserialized, zipped', async () => {
|
|
@@ -37,7 +39,6 @@ describe('stress', async function () {
|
|
|
37
39
|
let buff1 = Buffer.from(JSON.stringify(o()))
|
|
38
40
|
let buff2 = Buffer.from(JSON.stringify(o()))
|
|
39
41
|
let res = unpack<any>(pack(buff1, opts), opts)
|
|
40
|
-
|
|
41
42
|
for (let i = 0; i < buff2.length; i++)
|
|
42
43
|
expect(res[i]).to.equal(buff2[i])
|
|
43
44
|
|
package/src/test/performance.ts
CHANGED
|
@@ -4,16 +4,16 @@ import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
|
4
4
|
import { EchoWorker } from "../echoWorker";
|
|
5
5
|
import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
6
6
|
|
|
7
|
-
describe('
|
|
8
|
-
|
|
9
|
-
this.timeout(10000)
|
|
7
|
+
describe('performance', async function () {
|
|
10
8
|
|
|
9
|
+
this.timeout(160000)
|
|
11
10
|
new Broker().start()
|
|
12
|
-
new DelayWorker().start()
|
|
13
11
|
new EchoWorker().start()
|
|
12
|
+
new DelayWorker().start()
|
|
13
|
+
|
|
14
14
|
let client = new Client()
|
|
15
15
|
|
|
16
|
-
let requestSizes = [1, 10, 100, 1000, 10000]
|
|
16
|
+
let requestSizes = [1, 10, 100, 1000, 10000, 100000]
|
|
17
17
|
|
|
18
18
|
function sizedRq(size: number) {
|
|
19
19
|
let bigRequest = Array(size)
|
|
@@ -29,7 +29,8 @@ describe('stress', async function () {
|
|
|
29
29
|
|
|
30
30
|
async function measure(name: string, opts: Partial<EbusRequestOptions>) {
|
|
31
31
|
let sizedRequests = requestSizes.map(r => sizedRq(r))
|
|
32
|
-
let line
|
|
32
|
+
let line: any[] = [name]
|
|
33
|
+
|
|
33
34
|
for (let req of sizedRequests) {
|
|
34
35
|
let start = new Date().valueOf()
|
|
35
36
|
let rep = await client.request<any>("delay", { delay: 10, req }, opts)
|
|
@@ -41,13 +42,13 @@ describe('stress', async function () {
|
|
|
41
42
|
printLine(line)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
it('should
|
|
45
|
-
|
|
45
|
+
it('should measure raw', async () => {
|
|
46
|
+
|
|
46
47
|
printLine([ 'opts', ...requestSizes ])
|
|
47
|
-
|
|
48
|
-
await measure("+raw -zipped",{ raw:true, zip: false, receiveTimeout: 4000 })
|
|
49
|
-
|
|
50
|
-
await measure("+raw +zipped",{ raw:true, zip: true, receiveTimeout: 4000 })
|
|
48
|
+
await measure("-raw -zipped",{ raw:false, zip: false, receiveTimeout: 4000 })
|
|
49
|
+
// await measure("+raw -zipped",{ raw:true, zip: false, receiveTimeout: 4000 })
|
|
50
|
+
await measure("-raw +zipped",{ raw:false, zip: true, receiveTimeout: 4000 })
|
|
51
|
+
// await measure("+raw +zipped",{ raw:true, zip: true, receiveTimeout: 4000 })
|
|
51
52
|
|
|
52
53
|
});
|
|
53
54
|
|
package/src/test/pub.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { expect } from "chai"
|
|
2
|
-
import { Worker, worker } from "cluster";
|
|
3
1
|
import { Client } from "../client";
|
|
4
2
|
import { EchoWorker } from "../echoWorker";
|
|
5
3
|
import { ErrorWorker } from "../errorWorker";
|
|
6
|
-
import { Broker, DelayWorker
|
|
4
|
+
import { Broker, DelayWorker } from "../index";
|
|
7
5
|
import { RejectWorker } from "../rejectWorker";
|
|
8
6
|
import { Sub } from "../sub";
|
|
9
7
|
|
package/src/types.ts
CHANGED
package/src/worker.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Log , serialize} from "cry-helpers"
|
|
2
|
-
import { Dealer
|
|
2
|
+
import { Dealer } from "zeromq"
|
|
3
3
|
import { EbusConfiguration } from "./EbusConfiguration"
|
|
4
4
|
import { EbusRequestOptions } from "./EbusRequestOptions"
|
|
5
5
|
import { loadConfiguration } from "./loadConfiguration"
|
|
@@ -97,27 +97,39 @@ export class Worker {
|
|
|
97
97
|
|
|
98
98
|
try {
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
switch (type.toString()) {
|
|
101
|
+
case Message.Shutdown:
|
|
102
|
+
|
|
103
|
+
log.status(`worker for ${this.service} received broker shutdown signal`)
|
|
104
|
+
break;
|
|
105
|
+
|
|
106
|
+
case Message.Heartbeat:
|
|
107
|
+
|
|
108
|
+
log.trace(`worker for ${this.service} received heartbeat from broker`)
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case Message.ShutdownAndRestart:
|
|
112
|
+
|
|
113
|
+
log.status(`worker for ${this.service} received ShutdownAndRestart from broker`)
|
|
114
|
+
process.exit(1)
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
case Message.Request:
|
|
118
|
+
|
|
119
|
+
this.processing = true
|
|
120
|
+
await this.processRequest(reqId, optBuff, type, req, client)
|
|
121
|
+
this.processing = false
|
|
122
|
+
break;
|
|
123
|
+
|
|
124
|
+
default:
|
|
125
|
+
|
|
126
|
+
log.error(`worker for ${this.service} cannot process message type ${type}`, [blank1, header, type, client, blank2, reqId, optBuff, req])
|
|
127
|
+
log.error([blank1, header, type, client, blank2, reqId, optBuff, req])
|
|
115
128
|
|
|
116
|
-
} else {
|
|
117
|
-
|
|
118
|
-
log.error(`worker for ${this.service} cannot process message type ${type}`)
|
|
119
129
|
}
|
|
120
130
|
|
|
131
|
+
|
|
132
|
+
|
|
121
133
|
} catch (err) {
|
|
122
134
|
console.error(`error in worker for '${this.service}'`)
|
|
123
135
|
console.error(err)
|
|
@@ -151,14 +163,14 @@ export class Worker {
|
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
// to be implemented at the actual worker
|
|
154
|
-
public async onError(err:any)
|
|
166
|
+
public async onError(err:any, req: any, opts: any)
|
|
155
167
|
{
|
|
156
168
|
console.log('worker/onError - should override');
|
|
157
169
|
|
|
158
170
|
}
|
|
159
171
|
|
|
160
172
|
private async processRequest(reqId: Buffer, optBuff: Buffer, type: Buffer, req: Buffer, client: Buffer) {
|
|
161
|
-
|
|
173
|
+
|
|
162
174
|
let opts = serialize.unpack(optBuff) as Partial<EbusRequestOptions>
|
|
163
175
|
log.debug(`worker for ${this.service} received request ${type} with opts`, opts)
|
|
164
176
|
|
|
@@ -176,11 +188,13 @@ export class Worker {
|
|
|
176
188
|
rep = await Promise.race(promises)
|
|
177
189
|
if (rep instanceof EbusRejectError && rep.reason === "timeout") {
|
|
178
190
|
log.warn(`request expired at worker for '${this.service}' after ${timeout} ms with opts ${serialize.pack(opts)}`)
|
|
191
|
+
console.log('opts',opts);
|
|
192
|
+
|
|
179
193
|
log.warn(unpack(req, opts))
|
|
180
194
|
responseMessageType = Message.Timeout
|
|
181
|
-
this.onError("timeout");
|
|
195
|
+
this.onError("timeout", unpack(req, opts), opts);
|
|
182
196
|
}
|
|
183
|
-
} catch (err) {
|
|
197
|
+
} catch (err:any) {
|
|
184
198
|
rep = err
|
|
185
199
|
if (!(rep instanceof EbusRejectError)) {
|
|
186
200
|
rep = new EbusRejectError("error", `error in worker for '${this.service}' process method: '${err.message}'`, err);
|
|
@@ -193,7 +207,7 @@ export class Worker {
|
|
|
193
207
|
if (rep instanceof EbusRejectError && rep.reason === "error")
|
|
194
208
|
responseMessageType = Message.Error
|
|
195
209
|
|
|
196
|
-
this.onError(err);
|
|
210
|
+
this.onError(err, unpack(req, opts), opts );
|
|
197
211
|
}
|
|
198
212
|
|
|
199
213
|
let data = rep;
|