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.
Files changed (185) hide show
  1. package/dist/EbusReject.d.ts +1 -1
  2. package/dist/EbusReject.d.ts.map +1 -1
  3. package/dist/EbusUnpackedResult.d.ts +1 -1
  4. package/dist/EbusUnpackedResult.d.ts.map +1 -1
  5. package/dist/EbusUnpackedResult.js +7 -7
  6. package/dist/EbusUnpackedResult.js.map +1 -1
  7. package/dist/broker.d.ts +3 -2
  8. package/dist/broker.d.ts.map +1 -1
  9. package/dist/broker.js +33 -33
  10. package/dist/broker.js.map +1 -1
  11. package/dist/client.d.ts +1 -1
  12. package/dist/client.d.ts.map +1 -1
  13. package/dist/client.js +2 -2
  14. package/dist/client.js.map +1 -1
  15. package/dist/clientBlocking.d.ts +6 -6
  16. package/dist/clientBlocking.d.ts.map +1 -1
  17. package/dist/clientBlocking.js +20 -20
  18. package/dist/clientBlocking.js.map +1 -1
  19. package/dist/clientNonBlocking.d.ts +6 -6
  20. package/dist/clientNonBlocking.d.ts.map +1 -1
  21. package/dist/clientNonBlocking.js +30 -30
  22. package/dist/clientNonBlocking.js.map +1 -1
  23. package/dist/consts.d.ts +1 -1
  24. package/dist/consts.d.ts.map +1 -1
  25. package/dist/delayWorker.d.ts +1 -1
  26. package/dist/delayWorker.d.ts.map +1 -1
  27. package/dist/delayWorker.js +6 -6
  28. package/dist/delayWorker.js.map +1 -1
  29. package/dist/echoWorker.d.ts +1 -1
  30. package/dist/echoWorker.d.ts.map +1 -1
  31. package/dist/echoWorker.js +4 -4
  32. package/dist/echoWorker.js.map +1 -1
  33. package/dist/errorWorker.d.ts +1 -1
  34. package/dist/errorWorker.d.ts.map +1 -1
  35. package/dist/errorWorker.js +6 -6
  36. package/dist/errorWorker.js.map +1 -1
  37. package/dist/index.d.ts +18 -18
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +21 -17
  40. package/dist/index.js.map +1 -1
  41. package/dist/loadConfiguration.d.ts +1 -1
  42. package/dist/loadConfiguration.d.ts.map +1 -1
  43. package/dist/loadConfiguration.js +2 -2
  44. package/dist/loadConfiguration.js.map +1 -1
  45. package/dist/pub.d.ts +1 -1
  46. package/dist/pub.d.ts.map +1 -1
  47. package/dist/pub.js +4 -4
  48. package/dist/pub.js.map +1 -1
  49. package/dist/rejectWorker.d.ts +1 -1
  50. package/dist/rejectWorker.d.ts.map +1 -1
  51. package/dist/rejectWorker.js +6 -6
  52. package/dist/rejectWorker.js.map +1 -1
  53. package/dist/run/all.js +10 -10
  54. package/dist/run/all.js.map +1 -1
  55. package/dist/run/broker.d.mts +2 -0
  56. package/dist/run/broker.d.mts.map +1 -0
  57. package/dist/run/broker.mjs +5 -0
  58. package/dist/run/broker.mjs.map +1 -0
  59. package/dist/run/call.js +16 -11
  60. package/dist/run/call.js.map +1 -1
  61. package/dist/run/calling.js +4 -4
  62. package/dist/run/calling.js.map +1 -1
  63. package/dist/run/callingBurst.js +4 -4
  64. package/dist/run/callingBurst.js.map +1 -1
  65. package/dist/run/delay.d.mts +2 -0
  66. package/dist/run/delay.d.mts.map +1 -0
  67. package/dist/run/delay.mjs +5 -0
  68. package/dist/run/delay.mjs.map +1 -0
  69. package/dist/run/echo.d.mts +2 -0
  70. package/dist/run/echo.d.mts.map +1 -0
  71. package/dist/run/echo.mjs +5 -0
  72. package/dist/run/echo.mjs.map +1 -0
  73. package/dist/run/error.d.mts +2 -0
  74. package/dist/run/error.d.mts.map +1 -0
  75. package/dist/run/error.mjs +5 -0
  76. package/dist/run/error.mjs.map +1 -0
  77. package/dist/run/ping.d.mts +2 -0
  78. package/dist/run/ping.d.mts.map +1 -0
  79. package/dist/run/{ping.js → ping.mjs} +21 -22
  80. package/dist/run/ping.mjs.map +1 -0
  81. package/dist/run/pub.js +2 -2
  82. package/dist/run/pub.js.map +1 -1
  83. package/dist/run/reject.js +2 -2
  84. package/dist/run/reject.js.map +1 -1
  85. package/dist/run/sub.js +27 -26
  86. package/dist/run/sub.js.map +1 -1
  87. package/dist/run/workers.js +10 -14
  88. package/dist/run/workers.js.map +1 -1
  89. package/dist/serialize.d.ts +1 -1
  90. package/dist/serialize.d.ts.map +1 -1
  91. package/dist/service.js +6 -6
  92. package/dist/service.js.map +1 -1
  93. package/dist/sub.d.ts +1 -1
  94. package/dist/sub.d.ts.map +1 -1
  95. package/dist/sub.js +4 -4
  96. package/dist/sub.js.map +1 -1
  97. package/dist/test/config.js +6 -6
  98. package/dist/test/config.js.map +1 -1
  99. package/dist/test/echo.js +11 -11
  100. package/dist/test/echo.js.map +1 -1
  101. package/dist/test/index.d.ts +1 -0
  102. package/dist/test/index.js +1 -0
  103. package/dist/test/index.js.map +1 -1
  104. package/dist/test/pack.js +15 -15
  105. package/dist/test/pack.js.map +1 -1
  106. package/dist/test/performance.js +7 -7
  107. package/dist/test/performance.js.map +1 -1
  108. package/dist/test/pub.js +14 -14
  109. package/dist/test/pub.js.map +1 -1
  110. package/dist/test/pub2.js +8 -8
  111. package/dist/test/pub2.js.map +1 -1
  112. package/dist/test/reject.js +8 -8
  113. package/dist/test/reject.js.map +1 -1
  114. package/dist/test/services.js +9 -9
  115. package/dist/test/services.js.map +1 -1
  116. package/dist/test/stress.js +5 -5
  117. package/dist/test/stress.js.map +1 -1
  118. package/dist/test/timing.js +12 -12
  119. package/dist/test/timing.js.map +1 -1
  120. package/dist/worker.d.ts +2 -2
  121. package/dist/worker.d.ts.map +1 -1
  122. package/dist/worker.js +35 -35
  123. package/dist/worker.js.map +1 -1
  124. package/package.json +17 -13
  125. package/src/EbusReject.ts +1 -1
  126. package/src/EbusUnpackedResult.ts +3 -3
  127. package/src/broker.ts +6 -6
  128. package/src/client.ts +1 -1
  129. package/src/clientBlocking.ts +9 -9
  130. package/src/clientNonBlocking.ts +9 -9
  131. package/src/consts.ts +1 -1
  132. package/src/delayWorker.ts +3 -3
  133. package/src/echoWorker.ts +2 -2
  134. package/src/errorWorker.ts +3 -3
  135. package/src/index.ts +18 -18
  136. package/src/loadConfiguration.ts +2 -2
  137. package/src/pub.ts +3 -3
  138. package/src/rejectWorker.ts +3 -4
  139. package/src/run/all.ts +5 -6
  140. package/src/run/{broker.ts → broker.mts} +1 -1
  141. package/src/run/call.ts +26 -11
  142. package/src/run/calling.ts +2 -2
  143. package/src/run/callingBurst.ts +2 -2
  144. package/src/run/{delay.ts → delay.mts} +1 -1
  145. package/src/run/{echo.ts → echo.mts} +1 -1
  146. package/src/run/{error.ts → error.mts} +1 -1
  147. package/src/run/{ping.ts → ping.mts} +10 -9
  148. package/src/run/pub.ts +1 -1
  149. package/src/run/reject.ts +1 -1
  150. package/src/run/sub.ts +23 -22
  151. package/src/run/workers.ts +8 -14
  152. package/src/serialize.ts +1 -1
  153. package/src/service.ts +1 -1
  154. package/src/sub.ts +4 -4
  155. package/src/test/config.ts +3 -3
  156. package/src/test/echo.ts +4 -4
  157. package/src/test/pack.ts +1 -3
  158. package/src/test/performance.ts +4 -4
  159. package/src/test/pub.ts +6 -6
  160. package/src/test/pub2.ts +4 -6
  161. package/src/test/reject.ts +4 -5
  162. package/src/test/services.ts +3 -3
  163. package/src/test/stress.ts +2 -2
  164. package/src/test/timing.ts +5 -5
  165. package/src/worker.ts +7 -7
  166. package/tsconfig.json +2 -2
  167. package/dist/run/broker.d.ts +0 -2
  168. package/dist/run/broker.d.ts.map +0 -1
  169. package/dist/run/broker.js +0 -7
  170. package/dist/run/broker.js.map +0 -1
  171. package/dist/run/delay.d.ts +0 -2
  172. package/dist/run/delay.d.ts.map +0 -1
  173. package/dist/run/delay.js +0 -7
  174. package/dist/run/delay.js.map +0 -1
  175. package/dist/run/echo.d.ts +0 -2
  176. package/dist/run/echo.d.ts.map +0 -1
  177. package/dist/run/echo.js +0 -7
  178. package/dist/run/echo.js.map +0 -1
  179. package/dist/run/error.d.ts +0 -2
  180. package/dist/run/error.d.ts.map +0 -1
  181. package/dist/run/error.js +0 -7
  182. package/dist/run/error.js.map +0 -1
  183. package/dist/run/ping.d.ts +0 -2
  184. package/dist/run/ping.d.ts.map +0 -1
  185. 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)
@@ -1,7 +1,6 @@
1
- import { block } from "./block"
2
- import { EbusRejectError } from "./EbusReject"
3
- import { sleep } from "./sleep"
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()
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { config } from "dotenv"
3
- import { Broker } from "../broker";
3
+ import { Broker } from "../broker.js";
4
4
 
5
5
  config()
6
6
  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 { Client } from "../client";
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(program.repeat)
45
+ let repeat = parseInt(myProgram.repeat)
46
+ let start = new Date().valueOf()
34
47
  if (isNaN(repeat)) repeat = 1;
35
- if (program.timeout === NaN) exitProgram("timeout must be a number");
36
- if (typeof program.timeout==="number") opts.receiveTimeout=program.timeout
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 (!program.silent) {
51
+ if (!myProgram.silent) {
39
52
  console.log('');
40
- console.log(`${program.dryRun ? 'would ' : ''}call \x1b[7m ${worker} \x1b[27m`, opts)
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 (!program.dryRun) {
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(program.depth) || 3
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 (!program.silent) console.log();
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
 
@@ -1,6 +1,6 @@
1
1
  import { config } from "dotenv"
2
- import { Client } from "../index"
3
- import { sleep } from "../sleep"
2
+ import { Client } from "../index.js"
3
+ import { sleep } from "../sleep.js"
4
4
 
5
5
  config()
6
6
  let client = new Client()
@@ -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,6 +1,6 @@
1
1
 
2
2
  import { config } from "dotenv"
3
- import { DelayWorker } from "../delayWorker"
3
+ import { DelayWorker } from "../delayWorker.js"
4
4
 
5
5
  config()
6
6
  new DelayWorker().start()
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { config } from "dotenv"
3
- import { EchoWorker } from "../echoWorker"
3
+ import { EchoWorker } from "../echoWorker.js"
4
4
 
5
5
  config()
6
6
  new EchoWorker().start()
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { config } from "dotenv"
3
- import { ErrorWorker } from "../errorWorker"
3
+ import { ErrorWorker } from "../errorWorker.js"
4
4
 
5
5
  config()
6
6
  new ErrorWorker().start()
@@ -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 (program.timeout === NaN) exitProgram("timeout must be a number");
36
- if (typeof program.timeout==="number") opts.receiveTimeout=program.timeout
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 (!program.silent) {
39
+ if (!myProgram.silent) {
39
40
  console.log('');
40
- console.log(`${program.dryRun?'would ':''}ping \x1b[7m ${workers} \x1b[27m`)
41
+ console.log(`${myProgram.dryRun?'would ':''}ping \x1b[7m ${workers} \x1b[27m`)
41
42
  console.log('')
42
43
  }
43
44
 
44
- if (!program.dryRun) {
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 (!program.silent) console.log();
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
- program.parse(process.argv);
69
+ myProgram.parse(process.argv);
69
70
 
70
71
  function tryParseJson(str: string) {
71
72
  try {
package/src/run/pub.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { objStrToJson } from "cry-helpers";
4
4
  import { config } from "dotenv";
5
- import { Client } from "../client";
5
+ import { Client } from "../client.js";
6
6
 
7
7
  config()
8
8
  let client = new Client()
package/src/run/reject.ts CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { config } from "dotenv"
3
- import { RejectWorker } from "../rejectWorker"
3
+ import { RejectWorker } from "../rejectWorker.js"
4
4
 
5
5
  config()
6
6
  new RejectWorker().start()
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 TX from "./termimalCommands"
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 program.connect === "boolean"
33
- || typeof program.disconnect === "boolean"
34
- || typeof program.message === "boolean";
33
+ typeof myProgram.connect === "boolean"
34
+ || typeof myProgram.disconnect === "boolean"
35
+ || typeof myProgram.message === "boolean";
35
36
 
36
37
  if (!sthDefined)
37
- program.connect = program.disconnect = program.message = true
38
+ myProgram.connect = myProgram.disconnect = myProgram.message = true
38
39
 
39
- console.log('program.connect', program.connect);
40
- console.log('program.disconnect', program.disconnect);
41
- console.log('program.message', program.message);
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 (!(program.connect || program.disconnect || program.message)) {
48
- if (!program.silent) console.log("WARN: not listening to any events.")
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 (!program.dryRun) {
53
- if (!program.silent) console.log('start receiving\n');
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 (program.disconnect) {
64
- if (!program.silent)
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 (program.connect) {
74
- if (!program.silent)
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 (program.message) {
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 (!program.subscribe.length) {
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
- program.subscribe.forEach(async (c: string) => await sub.subscribe(c));
96
- stxt = `on channels ${TX.fgYellow}${program.subscribe.join(", ")}`;
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 (!program.silent)
100
+ if (!myProgram.silent)
100
101
  console.log(`listen to ${TX.fgGreen}message${TX.reset} events`, stxt, TX.reset);
101
102
  }
102
103
 
@@ -1,10 +1,9 @@
1
1
 
2
- import { objStrToJson } from "cry-helpers";
3
2
  import { config } from "dotenv";
4
- import { Client } from "../client";
5
- import { program } from "commander"
6
- import { EbusRequestOptions } from "../EbusRequestOptions";
7
- import { exit } from "process";
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
@@ -1,6 +1,6 @@
1
1
  import { Log } from "cry-helpers"
2
2
  import { Router } from "zeromq"
3
- import { Header, Message } from "./types"
3
+ import { Header, Message } from "./types.js"
4
4
  const prefixes = ["EBUS_BROKER", "EBUS"]
5
5
  const log = new Log(prefixes)
6
6
  export class Service {
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") {
@@ -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
@@ -1,8 +1,6 @@
1
1
 
2
2
  import { expect } from "chai";
3
- import exp from "constants";
4
- import { DESTRUCTION } from "dns";
5
- import { unpack, pack } from "../index";
3
+ import { unpack, pack } from "../index.js";
6
4
 
7
5
  const largeArray = () => [
8
6
  /* 1 */
@@ -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 { ErrorWorker } from "../errorWorker";
4
- import { Broker, DelayWorker, unpack, pack } 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 { Broker } from "../index.js";
4
+ import { Sub } from "../sub.js";
7
5
 
8
6
  describe('pub/sub', async function () {
9
7
 
@@ -1,10 +1,9 @@
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 { Broker, DelayWorker, unpack, pack } from "../index";
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
 
@@ -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
 
@@ -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
 
@@ -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": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
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": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
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. */,
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=broker.d.ts.map