cry-ebus2 3.0.9 → 3.1.2
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/EbusReject.d.ts +1 -1
- package/dist/EbusReject.d.ts.map +1 -1
- package/dist/EbusUnpackedResult.d.ts +1 -1
- package/dist/EbusUnpackedResult.d.ts.map +1 -1
- package/dist/EbusUnpackedResult.js +7 -7
- package/dist/EbusUnpackedResult.js.map +1 -1
- package/dist/broker.d.ts +3 -2
- package/dist/broker.d.ts.map +1 -1
- package/dist/broker.js +33 -33
- package/dist/broker.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/clientBlocking.d.ts +6 -6
- package/dist/clientBlocking.d.ts.map +1 -1
- package/dist/clientBlocking.js +20 -20
- package/dist/clientBlocking.js.map +1 -1
- package/dist/clientNonBlocking.d.ts +6 -6
- package/dist/clientNonBlocking.d.ts.map +1 -1
- package/dist/clientNonBlocking.js +30 -30
- package/dist/clientNonBlocking.js.map +1 -1
- package/dist/consts.d.ts +1 -1
- package/dist/consts.d.ts.map +1 -1
- package/dist/delayWorker.d.ts +1 -1
- package/dist/delayWorker.d.ts.map +1 -1
- package/dist/delayWorker.js +6 -6
- package/dist/delayWorker.js.map +1 -1
- package/dist/echoWorker.d.ts +1 -1
- package/dist/echoWorker.d.ts.map +1 -1
- package/dist/echoWorker.js +4 -4
- package/dist/echoWorker.js.map +1 -1
- package/dist/errorWorker.d.ts +1 -1
- package/dist/errorWorker.d.ts.map +1 -1
- package/dist/errorWorker.js +6 -6
- package/dist/errorWorker.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -17
- package/dist/index.js.map +1 -1
- package/dist/loadConfiguration.d.ts +1 -1
- package/dist/loadConfiguration.d.ts.map +1 -1
- package/dist/loadConfiguration.js +2 -2
- package/dist/loadConfiguration.js.map +1 -1
- package/dist/pub.d.ts +1 -1
- package/dist/pub.d.ts.map +1 -1
- package/dist/pub.js +4 -4
- package/dist/pub.js.map +1 -1
- package/dist/rejectWorker.d.ts +1 -1
- package/dist/rejectWorker.d.ts.map +1 -1
- package/dist/rejectWorker.js +6 -6
- package/dist/rejectWorker.js.map +1 -1
- package/dist/run/all.js +10 -10
- package/dist/run/all.js.map +1 -1
- package/dist/run/broker.d.mts +2 -0
- package/dist/run/broker.d.mts.map +1 -0
- package/dist/run/broker.mjs +5 -0
- package/dist/run/broker.mjs.map +1 -0
- package/dist/run/call.js +16 -11
- package/dist/run/call.js.map +1 -1
- package/dist/run/calling.js +4 -4
- package/dist/run/calling.js.map +1 -1
- package/dist/run/callingBurst.js +4 -4
- package/dist/run/callingBurst.js.map +1 -1
- package/dist/run/delay.d.mts +2 -0
- package/dist/run/delay.d.mts.map +1 -0
- package/dist/run/delay.mjs +5 -0
- package/dist/run/delay.mjs.map +1 -0
- package/dist/run/echo.d.mts +2 -0
- package/dist/run/echo.d.mts.map +1 -0
- package/dist/run/echo.mjs +5 -0
- package/dist/run/echo.mjs.map +1 -0
- package/dist/run/error.d.mts +2 -0
- package/dist/run/error.d.mts.map +1 -0
- package/dist/run/error.mjs +5 -0
- package/dist/run/error.mjs.map +1 -0
- package/dist/run/ping.d.mts +2 -0
- package/dist/run/ping.d.mts.map +1 -0
- package/dist/run/{ping.js → ping.mjs} +21 -22
- package/dist/run/ping.mjs.map +1 -0
- package/dist/run/pub.js +2 -2
- package/dist/run/pub.js.map +1 -1
- package/dist/run/reject.js +2 -2
- package/dist/run/reject.js.map +1 -1
- package/dist/run/sub.js +27 -26
- package/dist/run/sub.js.map +1 -1
- package/dist/run/workers.js +10 -14
- package/dist/run/workers.js.map +1 -1
- package/dist/serialize.d.ts +1 -1
- package/dist/serialize.d.ts.map +1 -1
- package/dist/service.js +6 -6
- package/dist/service.js.map +1 -1
- package/dist/sub.d.ts +1 -1
- package/dist/sub.d.ts.map +1 -1
- package/dist/sub.js +4 -4
- package/dist/sub.js.map +1 -1
- package/dist/test/config.js +6 -6
- package/dist/test/config.js.map +1 -1
- package/dist/test/echo.js +11 -11
- package/dist/test/echo.js.map +1 -1
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/pack.js +15 -15
- package/dist/test/pack.js.map +1 -1
- package/dist/test/performance.js +7 -7
- package/dist/test/performance.js.map +1 -1
- package/dist/test/pub.js +14 -14
- package/dist/test/pub.js.map +1 -1
- package/dist/test/pub2.js +8 -8
- package/dist/test/pub2.js.map +1 -1
- package/dist/test/reject.js +8 -8
- 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 +5 -5
- package/dist/test/stress.js.map +1 -1
- package/dist/test/timing.js +12 -12
- package/dist/test/timing.js.map +1 -1
- package/dist/worker.d.ts +2 -2
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +35 -35
- package/dist/worker.js.map +1 -1
- package/package.json +17 -13
- package/src/EbusReject.ts +1 -1
- package/src/EbusUnpackedResult.ts +3 -3
- package/src/broker.ts +6 -6
- package/src/client.ts +1 -1
- package/src/clientBlocking.ts +9 -9
- package/src/clientNonBlocking.ts +9 -9
- package/src/consts.ts +1 -1
- package/src/delayWorker.ts +3 -3
- package/src/echoWorker.ts +2 -2
- package/src/errorWorker.ts +3 -3
- package/src/index.ts +18 -18
- package/src/loadConfiguration.ts +2 -2
- package/src/pub.ts +3 -3
- package/src/rejectWorker.ts +3 -4
- package/src/run/all.ts +5 -6
- package/src/run/{broker.ts → broker.mts} +1 -1
- package/src/run/call.ts +26 -11
- package/src/run/calling.ts +2 -2
- package/src/run/callingBurst.ts +2 -2
- package/src/run/{delay.ts → delay.mts} +1 -1
- package/src/run/{echo.ts → echo.mts} +1 -1
- package/src/run/{error.ts → error.mts} +1 -1
- package/src/run/{ping.ts → ping.mts} +10 -9
- package/src/run/pub.ts +1 -1
- package/src/run/reject.ts +1 -1
- package/src/run/sub.ts +23 -22
- package/src/run/workers.ts +8 -14
- package/src/serialize.ts +1 -1
- package/src/service.ts +1 -1
- package/src/sub.ts +4 -4
- package/src/test/config.ts +3 -3
- package/src/test/echo.ts +4 -4
- package/src/test/pack.ts +1 -3
- package/src/test/performance.ts +4 -4
- package/src/test/pub.ts +6 -6
- package/src/test/pub2.ts +4 -6
- package/src/test/reject.ts +4 -5
- package/src/test/services.ts +3 -3
- package/src/test/stress.ts +2 -2
- package/src/test/timing.ts +5 -5
- package/src/worker.ts +7 -7
- package/tsconfig.json +2 -2
- package/dist/run/broker.d.ts +0 -2
- package/dist/run/broker.d.ts.map +0 -1
- package/dist/run/broker.js +0 -7
- package/dist/run/broker.js.map +0 -1
- package/dist/run/delay.d.ts +0 -2
- package/dist/run/delay.d.ts.map +0 -1
- package/dist/run/delay.js +0 -7
- package/dist/run/delay.js.map +0 -1
- package/dist/run/echo.d.ts +0 -2
- package/dist/run/echo.d.ts.map +0 -1
- package/dist/run/echo.js +0 -7
- package/dist/run/echo.js.map +0 -1
- package/dist/run/error.d.ts +0 -2
- package/dist/run/error.d.ts.map +0 -1
- package/dist/run/error.js +0 -7
- package/dist/run/error.js.map +0 -1
- package/dist/run/ping.d.ts +0 -2
- package/dist/run/ping.d.ts.map +0 -1
- package/dist/run/ping.js.map +0 -1
package/src/pub.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { Log } from "cry-helpers"
|
|
3
3
|
import { Publisher } from "zeromq"
|
|
4
|
-
import { EbusConfiguration } from "./EbusConfiguration"
|
|
5
|
-
import { loadConfiguration } from "./loadConfiguration"
|
|
6
|
-
import { pack } from "./serialize"
|
|
4
|
+
import { EbusConfiguration } from "./EbusConfiguration.js"
|
|
5
|
+
import { loadConfiguration } from "./loadConfiguration.js"
|
|
6
|
+
import { pack } from "./serialize.js"
|
|
7
7
|
|
|
8
8
|
const prefixes = ["EBUS_PUB", "EBUS"]
|
|
9
9
|
const log = new Log(prefixes)
|
package/src/rejectWorker.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Worker } from "./worker"
|
|
1
|
+
import { EbusRejectError } from "./EbusReject.js"
|
|
2
|
+
import { sleep } from "./sleep.js"
|
|
3
|
+
import { Worker } from "./worker.js"
|
|
5
4
|
|
|
6
5
|
export interface RejectRequest
|
|
7
6
|
{
|
package/src/run/all.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Broker } from "../broker";
|
|
2
|
-
import { DelayWorker } from "../delayWorker";
|
|
3
|
-
import { EchoWorker } from "../echoWorker";
|
|
4
|
-
import { ErrorWorker } from "../errorWorker";
|
|
5
|
-
import { RejectWorker } from "../rejectWorker";
|
|
1
|
+
import { Broker } from "../broker.js";
|
|
2
|
+
import { DelayWorker } from "../delayWorker.js";
|
|
3
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
4
|
+
import { ErrorWorker } from "../errorWorker.js";
|
|
5
|
+
import { RejectWorker } from "../rejectWorker.js";
|
|
6
6
|
|
|
7
7
|
import { config } from "dotenv"
|
|
8
|
-
import { Sub } from "../sub";
|
|
9
8
|
config()
|
|
10
9
|
|
|
11
10
|
new Broker().start()
|
package/src/run/call.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { objStrToJson } from "cry-helpers";
|
|
3
3
|
import { config } from "dotenv";
|
|
4
|
-
import {
|
|
5
|
-
import { program } from "commander"
|
|
6
|
-
import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
4
|
+
import { Command, program } from "commander"
|
|
7
5
|
import { exit } from "process";
|
|
6
|
+
import { Client } from "../client.js";
|
|
7
|
+
import { EbusRequestOptions } from "../EbusRequestOptions.js";
|
|
8
8
|
|
|
9
9
|
config();
|
|
10
10
|
|
|
@@ -12,6 +12,17 @@ program.version('0.0.2');
|
|
|
12
12
|
|
|
13
13
|
let client = new Client()
|
|
14
14
|
|
|
15
|
+
interface MyCommand extends Command {
|
|
16
|
+
timeout: number
|
|
17
|
+
repeat: string
|
|
18
|
+
silent: string
|
|
19
|
+
dryRun: string
|
|
20
|
+
depth: string
|
|
21
|
+
measure: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const myProgram = program as MyCommand
|
|
25
|
+
|
|
15
26
|
function exitProgram(message: string)
|
|
16
27
|
{
|
|
17
28
|
console.error(message)
|
|
@@ -24,35 +35,37 @@ program
|
|
|
24
35
|
.option('-r, --repeat <repeat>', 'repeat n times', "1")
|
|
25
36
|
.option('-d, --depth <depth>', 'json output depth', "3")
|
|
26
37
|
.option('-n, --dry-run', 'do not call, just report')
|
|
38
|
+
.option('-m, --measure', 'measure call duration')
|
|
27
39
|
.option('-S, --silent', 'do not output progress')
|
|
28
40
|
.arguments('<worker> [params]')
|
|
29
41
|
.action(async (worker,params) => {
|
|
30
42
|
|
|
31
43
|
let workload = tryParseJson(params || '')
|
|
32
44
|
let opts: Partial<EbusRequestOptions> | undefined = {}
|
|
33
|
-
let repeat = parseInt(
|
|
45
|
+
let repeat = parseInt(myProgram.repeat)
|
|
46
|
+
let start = new Date().valueOf()
|
|
34
47
|
if (isNaN(repeat)) repeat = 1;
|
|
35
|
-
if (
|
|
36
|
-
if (typeof
|
|
48
|
+
if (myProgram.timeout === NaN) exitProgram("timeout must be a number");
|
|
49
|
+
if (typeof myProgram.timeout==="number") opts.receiveTimeout=myProgram.timeout
|
|
37
50
|
if (Object.keys(opts).length === 0) opts = undefined;
|
|
38
|
-
if (!
|
|
51
|
+
if (!myProgram.silent) {
|
|
39
52
|
console.log('');
|
|
40
|
-
console.log(`${
|
|
53
|
+
console.log(`${myProgram.dryRun ? 'would ' : ''}call \x1b[7m ${worker} \x1b[27m`, opts)
|
|
41
54
|
if (repeat!==1)
|
|
42
55
|
console.log(`repeat \x1b[7m ${repeat} \x1b[27m times`, opts)
|
|
43
56
|
if (workload) console.log(`with ${typeof workload} message`, workload)
|
|
44
57
|
console.log('')
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
if (!
|
|
60
|
+
if (!myProgram.dryRun) {
|
|
48
61
|
try {
|
|
49
62
|
|
|
50
63
|
for (let i = 0; i < repeat; i++ ) {
|
|
51
64
|
let res = await client.request(worker, workload, opts)
|
|
52
|
-
let depth = Number.parseInt(
|
|
65
|
+
let depth = Number.parseInt(myProgram.depth) || 3
|
|
53
66
|
console.dir(res, { depth });
|
|
54
67
|
if (client.lastError) console.log(client.lastError);
|
|
55
|
-
if (!
|
|
68
|
+
if (!myProgram.silent) console.log();
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
} catch (err: any) {
|
|
@@ -62,6 +75,8 @@ program
|
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
|
|
78
|
+
if (myProgram.measure) console.log("elapsed time: ", new Date().valueOf() - start, "ms\n");
|
|
79
|
+
|
|
65
80
|
process.exit(0)
|
|
66
81
|
})
|
|
67
82
|
|
package/src/run/calling.ts
CHANGED
package/src/run/callingBurst.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from "dotenv";
|
|
2
|
-
import { ClientNonBlocking } from "../clientNonBlocking";
|
|
3
|
-
import { sleep } from "../sleep";
|
|
2
|
+
import { ClientNonBlocking } from "../clientNonBlocking.js";
|
|
3
|
+
import { sleep } from "../sleep.js";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var myArgs = process.argv.slice(2);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { objStrToJson } from "cry-helpers";
|
|
3
3
|
import { config } from "dotenv";
|
|
4
|
-
import { Client } from "../client";
|
|
5
4
|
import { program } from "commander"
|
|
6
|
-
import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
7
5
|
import { exit } from "process";
|
|
6
|
+
import { Client } from "../client.js";
|
|
7
|
+
import { EbusRequestOptions } from "../EbusRequestOptions.js";
|
|
8
8
|
|
|
9
9
|
config();
|
|
10
10
|
|
|
11
11
|
program.version('0.0.2');
|
|
12
|
+
const myProgram = program as any // TODO: describe options
|
|
12
13
|
|
|
13
14
|
let client = new Client()
|
|
14
15
|
|
|
@@ -32,16 +33,16 @@ program
|
|
|
32
33
|
if (!workers?.length) workers = await client.workers();
|
|
33
34
|
|
|
34
35
|
let opts : Partial<EbusRequestOptions> | undefined = {}
|
|
35
|
-
if (
|
|
36
|
-
if (typeof
|
|
36
|
+
if (myProgram.timeout === NaN) exitProgram("timeout must be a number");
|
|
37
|
+
if (typeof myProgram.timeout==="number") opts.receiveTimeout=myProgram.timeout
|
|
37
38
|
if (Object.keys(opts).length === 0) opts = undefined;
|
|
38
|
-
if (!
|
|
39
|
+
if (!myProgram.silent) {
|
|
39
40
|
console.log('');
|
|
40
|
-
console.log(`${
|
|
41
|
+
console.log(`${myProgram.dryRun?'would ':''}ping \x1b[7m ${workers} \x1b[27m`)
|
|
41
42
|
console.log('')
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
if (!
|
|
45
|
+
if (!myProgram.dryRun) {
|
|
45
46
|
try {
|
|
46
47
|
|
|
47
48
|
for await (let worker of workers) {
|
|
@@ -53,7 +54,7 @@ program
|
|
|
53
54
|
else
|
|
54
55
|
console.log(worker, "\x1b[31m", client.lastError?.reason, "\x1b[0m", client.lastError?.rejectMessage || client.lastError, "\x1b[0m")
|
|
55
56
|
}
|
|
56
|
-
if (!
|
|
57
|
+
if (!myProgram.silent) console.log();
|
|
57
58
|
|
|
58
59
|
} catch (err: any) {
|
|
59
60
|
console.error(`\x1b[31munexpected error\x1b[0m ${err.message}`)
|
|
@@ -65,7 +66,7 @@ program
|
|
|
65
66
|
process.exit(0)
|
|
66
67
|
})
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
myProgram.parse(process.argv);
|
|
69
70
|
|
|
70
71
|
function tryParseJson(str: string) {
|
|
71
72
|
try {
|
package/src/run/pub.ts
CHANGED
package/src/run/reject.ts
CHANGED
package/src/run/sub.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { config } from "dotenv"
|
|
4
|
-
import { Sub } from "../sub";
|
|
5
4
|
import { program } from "commander"
|
|
6
|
-
import
|
|
5
|
+
import { Sub } from "../sub.js";
|
|
6
|
+
import TX from "./termimalCommands.js"
|
|
7
7
|
|
|
8
8
|
config()
|
|
9
9
|
|
|
@@ -12,6 +12,7 @@ function collect(value:string, previous:string[]) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
let sub = new Sub()
|
|
15
|
+
const myProgram = program as any // TODO: describe options
|
|
15
16
|
|
|
16
17
|
program
|
|
17
18
|
.description('listens to ebus events')
|
|
@@ -29,28 +30,28 @@ program
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
let sthDefined =
|
|
32
|
-
typeof
|
|
33
|
-
|| typeof
|
|
34
|
-
|| typeof
|
|
33
|
+
typeof myProgram.connect === "boolean"
|
|
34
|
+
|| typeof myProgram.disconnect === "boolean"
|
|
35
|
+
|| typeof myProgram.message === "boolean";
|
|
35
36
|
|
|
36
37
|
if (!sthDefined)
|
|
37
|
-
|
|
38
|
+
myProgram.connect = myProgram.disconnect = myProgram.message = true
|
|
38
39
|
|
|
39
|
-
console.log('
|
|
40
|
-
console.log('
|
|
41
|
-
console.log('
|
|
40
|
+
console.log('myProgram.connect', myProgram.connect);
|
|
41
|
+
console.log('myProgram.disconnect', myProgram.disconnect);
|
|
42
|
+
console.log('myProgram.message', myProgram.message);
|
|
42
43
|
|
|
43
44
|
messageEvents()
|
|
44
45
|
connectEvent()
|
|
45
46
|
disconnectEvent()
|
|
46
47
|
|
|
47
|
-
if (!(
|
|
48
|
-
if (!
|
|
48
|
+
if (!(myProgram.connect || myProgram.disconnect || myProgram.message)) {
|
|
49
|
+
if (!myProgram.silent) console.log("WARN: not listening to any events.")
|
|
49
50
|
process.exit(0)
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
if (!
|
|
53
|
-
if (!
|
|
53
|
+
if (!myProgram.dryRun) {
|
|
54
|
+
if (!myProgram.silent) console.log('start receiving\n');
|
|
54
55
|
await sub.startReceiving()
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -60,8 +61,8 @@ program
|
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
function disconnectEvent() {
|
|
63
|
-
if (
|
|
64
|
-
if (!
|
|
64
|
+
if (myProgram.disconnect) {
|
|
65
|
+
if (!myProgram.silent)
|
|
65
66
|
console.log(`listen to ${TX.fgGreen}disconnect${TX.reset} event`);
|
|
66
67
|
|
|
67
68
|
sub.on("disconnect", () => { console.log("DISCONNECT"); });
|
|
@@ -70,8 +71,8 @@ function disconnectEvent() {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
function connectEvent() {
|
|
73
|
-
if (
|
|
74
|
-
if (!
|
|
74
|
+
if (myProgram.connect) {
|
|
75
|
+
if (!myProgram.silent)
|
|
75
76
|
console.log(`listen to ${TX.fgGreen}connect${TX.reset} event`);
|
|
76
77
|
|
|
77
78
|
sub.on("connect", () => { console.log("CONNECT"); });
|
|
@@ -80,23 +81,23 @@ function connectEvent() {
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
async function messageEvents() {
|
|
83
|
-
if (
|
|
84
|
+
if (myProgram.message) {
|
|
84
85
|
|
|
85
86
|
sub.on("message", ([channel, message]) => { console.log(channel, message) })
|
|
86
87
|
|
|
87
88
|
let stxt = "";
|
|
88
|
-
if (!
|
|
89
|
+
if (!myProgram.subscribe.length) {
|
|
89
90
|
|
|
90
91
|
await sub.subscribe("");
|
|
91
92
|
stxt = "on all channels";
|
|
92
93
|
|
|
93
94
|
} else {
|
|
94
95
|
|
|
95
|
-
|
|
96
|
-
stxt = `on channels ${TX.fgYellow}${
|
|
96
|
+
myProgram.subscribe.forEach(async (c: string) => await sub.subscribe(c));
|
|
97
|
+
stxt = `on channels ${TX.fgYellow}${myProgram.subscribe.join(", ")}`;
|
|
97
98
|
|
|
98
99
|
}
|
|
99
|
-
if (!
|
|
100
|
+
if (!myProgram.silent)
|
|
100
101
|
console.log(`listen to ${TX.fgGreen}message${TX.reset} events`, stxt, TX.reset);
|
|
101
102
|
}
|
|
102
103
|
|
package/src/run/workers.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import { objStrToJson } from "cry-helpers";
|
|
3
2
|
import { config } from "dotenv";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { Command } from "commander"
|
|
4
|
+
import { Client } from "../client.js";
|
|
5
|
+
|
|
6
|
+
const program = new Command()
|
|
8
7
|
|
|
9
8
|
config();
|
|
10
9
|
|
|
@@ -12,11 +11,6 @@ program.version('0.0.2');
|
|
|
12
11
|
|
|
13
12
|
let client = new Client()
|
|
14
13
|
|
|
15
|
-
function exitProgram(message: string) {
|
|
16
|
-
console.error(message)
|
|
17
|
-
exit(2)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
14
|
program
|
|
21
15
|
.description('calls a worker')
|
|
22
16
|
.option('-w, --workers', 'get workers (default)', true)
|
|
@@ -26,11 +20,11 @@ program
|
|
|
26
20
|
|
|
27
21
|
try {
|
|
28
22
|
|
|
29
|
-
if (program.restart) {
|
|
30
|
-
console.log(`request restart of \x1b[32m${program.restart}\x1b[0m workers`)
|
|
31
|
-
await client.restartAllWorkers(program.restart);
|
|
23
|
+
if ((program as any).restart) {
|
|
24
|
+
console.log(`request restart of \x1b[32m${(program as any).restart}\x1b[0m workers`)
|
|
25
|
+
await client.restartAllWorkers((program as any).restart);
|
|
32
26
|
}
|
|
33
|
-
else if (program.services) {
|
|
27
|
+
else if ((program as any).services) {
|
|
34
28
|
let res = await client.services()
|
|
35
29
|
console.dir(res)
|
|
36
30
|
} else {
|
package/src/serialize.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { serialize } from "cry-helpers";
|
|
3
3
|
import { deflateRaw, inflateRaw } from "pako";
|
|
4
|
-
import { EbusRequestOptions } from "./EbusRequestOptions";
|
|
4
|
+
import { EbusRequestOptions } from "./EbusRequestOptions.js";
|
|
5
5
|
import notepack from "notepack.io"
|
|
6
6
|
|
|
7
7
|
export function pack(data: any, opts: Partial<EbusRequestOptions>)
|
package/src/service.ts
CHANGED
package/src/sub.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Log } from "cry-helpers"
|
|
2
|
+
import { unpack } from "cry-helpers/dist/serialize.js"
|
|
2
3
|
import { TypedEmitter } from "tiny-typed-emitter"
|
|
3
4
|
import { Subscriber } from "zeromq"
|
|
4
|
-
import { EbusConfiguration } from "./EbusConfiguration"
|
|
5
|
-
import { loadConfiguration } from "./loadConfiguration"
|
|
6
|
-
import { unpack } from "./serialize"
|
|
5
|
+
import { EbusConfiguration } from "./EbusConfiguration.js"
|
|
6
|
+
import { loadConfiguration } from "./loadConfiguration.js"
|
|
7
7
|
|
|
8
8
|
const prefixes = ["EBUS_SUB", "EBUS"]
|
|
9
9
|
const log = new Log(prefixes)
|
|
@@ -62,7 +62,7 @@ export class Sub extends TypedEmitter<EbusSubscriptionEvent> {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
private processMessage(messagePacked: Buffer, channel: Buffer) {
|
|
65
|
-
let message = unpack(messagePacked
|
|
65
|
+
let message = unpack(messagePacked)
|
|
66
66
|
log.debug(`sub message received on ${channel}`, message)
|
|
67
67
|
this.emit("message", [channel.toString(), message])
|
|
68
68
|
if (channel.toString() === "ebus/stop") {
|
package/src/test/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import { EchoWorker } from "../echoWorker";
|
|
5
|
-
import { Broker, DelayWorker } from "../index";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
5
|
+
import { Broker, DelayWorker } from "../index.js";
|
|
6
6
|
|
|
7
7
|
describe('services', async function () {
|
|
8
8
|
|
package/src/test/echo.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai"
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import { EbusUnpackedResult } from "../EbusUnpackedResult";
|
|
5
|
-
import { EchoWorker } from "../echoWorker";
|
|
6
|
-
import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { EbusUnpackedResult } from "../EbusUnpackedResult.js";
|
|
5
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
6
|
+
import { Broker, DelayWorker, unpack, pack } from "../index.js";
|
|
7
7
|
|
|
8
8
|
describe('echo worker', async function () {
|
|
9
9
|
|
package/src/test/pack.ts
CHANGED
package/src/test/performance.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { Client } from "../client";
|
|
3
|
-
import { EbusRequestOptions } from "../EbusRequestOptions";
|
|
4
|
-
import { EchoWorker } from "../echoWorker";
|
|
5
|
-
import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
2
|
+
import { Client } from "../client.js";
|
|
3
|
+
import { EbusRequestOptions } from "../EbusRequestOptions.js";
|
|
4
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
5
|
+
import { Broker, DelayWorker, unpack, pack } from "../index.js";
|
|
6
6
|
|
|
7
7
|
describe('performance', async function () {
|
|
8
8
|
|
package/src/test/pub.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Client } from "../client";
|
|
2
|
-
import { EchoWorker } from "../echoWorker";
|
|
3
|
-
import { ErrorWorker } from "../errorWorker";
|
|
4
|
-
import { Broker, DelayWorker } from "../index";
|
|
5
|
-
import { RejectWorker } from "../rejectWorker";
|
|
6
|
-
import { Sub } from "../sub";
|
|
1
|
+
import { Client } from "../client.js";
|
|
2
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
3
|
+
import { ErrorWorker } from "../errorWorker.js";
|
|
4
|
+
import { Broker, DelayWorker } from "../index.js";
|
|
5
|
+
import { RejectWorker } from "../rejectWorker.js";
|
|
6
|
+
import { Sub } from "../sub.js";
|
|
7
7
|
|
|
8
8
|
describe('pub/sub', async function () {
|
|
9
9
|
|
package/src/test/pub2.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Client } from "../client";
|
|
2
|
-
import { EchoWorker } from "../echoWorker";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { RejectWorker } from "../rejectWorker";
|
|
6
|
-
import { Sub } from "../sub";
|
|
1
|
+
import { Client } from "../client.js";
|
|
2
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
3
|
+
import { Broker } from "../index.js";
|
|
4
|
+
import { Sub } from "../sub.js";
|
|
7
5
|
|
|
8
6
|
describe('pub/sub', async function () {
|
|
9
7
|
|
package/src/test/reject.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai"
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { RejectWorker } from "../rejectWorker";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { ErrorWorker } from "../errorWorker.js";
|
|
5
|
+
import { Broker } from "../index.js";
|
|
6
|
+
import { RejectWorker } from "../rejectWorker.js";
|
|
8
7
|
|
|
9
8
|
describe('timing', async function () {
|
|
10
9
|
|
package/src/test/services.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import { EchoWorker } from "../echoWorker";
|
|
5
|
-
import { Broker, DelayWorker } from "../index";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
5
|
+
import { Broker, DelayWorker } from "../index.js";
|
|
6
6
|
|
|
7
7
|
describe('services', async function () {
|
|
8
8
|
|
package/src/test/stress.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai"
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { Broker, DelayWorker, unpack, pack } from "../index.js";
|
|
5
5
|
|
|
6
6
|
describe('stress', async function () {
|
|
7
7
|
|
package/src/test/timing.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { expect } from "chai"
|
|
3
|
-
import { Client } from "../client";
|
|
4
|
-
import { EchoWorker } from "../echoWorker";
|
|
5
|
-
import { ErrorWorker } from "../errorWorker";
|
|
6
|
-
import { RejectWorker } from "../rejectWorker";
|
|
7
|
-
import { Broker, DelayWorker, unpack, pack } from "../index";
|
|
3
|
+
import { Client } from "../client.js";
|
|
4
|
+
import { EchoWorker } from "../echoWorker.js";
|
|
5
|
+
import { ErrorWorker } from "../errorWorker.js";
|
|
6
|
+
import { RejectWorker } from "../rejectWorker.js";
|
|
7
|
+
import { Broker, DelayWorker, unpack, pack } from "../index.js";
|
|
8
8
|
|
|
9
9
|
describe('timing', async function () {
|
|
10
10
|
|
package/src/worker.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Log , serialize} from "cry-helpers"
|
|
2
2
|
import { Dealer } from "zeromq"
|
|
3
|
-
import { EbusConfiguration } from "./EbusConfiguration"
|
|
4
|
-
import { EbusRequestOptions } from "./EbusRequestOptions"
|
|
5
|
-
import { loadConfiguration } from "./loadConfiguration"
|
|
6
|
-
import { Header, Message } from "./types"
|
|
7
|
-
import { pack, unpack } from "./serialize"
|
|
8
|
-
import { sleep } from "./sleep"
|
|
9
|
-
import { EbusRejectError } from "./EbusReject"
|
|
3
|
+
import { EbusConfiguration } from "./EbusConfiguration.js"
|
|
4
|
+
import { EbusRequestOptions } from "./EbusRequestOptions.js"
|
|
5
|
+
import { loadConfiguration } from "./loadConfiguration.js"
|
|
6
|
+
import { Header, Message } from "./types.js"
|
|
7
|
+
import { pack, unpack } from "./serialize.js"
|
|
8
|
+
import { sleep } from "./sleep.js"
|
|
9
|
+
import { EbusRejectError } from "./EbusReject.js"
|
|
10
10
|
|
|
11
11
|
const prefixes = ["EBUS_WORKER", "EBUS"]
|
|
12
12
|
const log = new Log(prefixes)
|
package/tsconfig.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/* Basic Options */
|
|
6
6
|
// "incremental": true, /* Enable incremental compilation */
|
|
7
7
|
"target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
|
8
|
-
"module": "
|
|
8
|
+
"module": "NodeNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
9
9
|
"lib": ["es2018", "ES2018.AsyncIterable"] /* Specify library files to be included in the compilation. */,
|
|
10
10
|
//"allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
11
|
// "checkJs": true, /* Report errors in .js files. */
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
//"noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
43
43
|
|
|
44
44
|
/* Module Resolution Options */
|
|
45
|
-
"moduleResolution": "
|
|
45
|
+
"moduleResolution": "NodeNext" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
|
46
46
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
47
47
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
48
48
|
"rootDirs": ["src", "src/test"] /* List of root folders whose combined content represents the structure of the project at runtime. */,
|
package/dist/run/broker.d.ts
DELETED