File tree 2 files changed +30
-11
lines changed
2 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 8
8
"ts-node" : " >= 0"
9
9
},
10
10
"scripts" : {
11
+ "build" : " cd .. && pnpm build && cd ./examples && pnpm install" ,
11
12
"majordomo" : " ts-node ./majordomo/index.ts" ,
12
13
"queue" : " ts-node ./queue/index.ts" ,
13
14
"threaded-worker" : " ts-node ./threaded-worker/index.ts" ,
Original file line number Diff line number Diff line change
1
+ /* eslint-disable */
1
2
const zmq = require ( "zeromq/v5-compat" )
2
3
3
- const pub = zmq . socket ( "pub" )
4
- const sub = zmq . socket ( "sub" )
4
+ function main ( ) {
5
+ const pub = zmq . socket ( "pub" )
6
+ const sub = zmq . socket ( "sub" )
5
7
6
- pub . bind ( "tcp://*:3456" , err => {
7
- if ( err ) {
8
- throw err
9
- }
8
+ pub . on ( "bind" , address => {
9
+ console . log ( `Bound to ${ address } ` )
10
+ } )
11
+
12
+ pub . bind ( "tcp://127.0.0.1:3456" , err => {
13
+ if ( err ) {
14
+ throw err
15
+ }
10
16
11
- sub . connect ( "tcp://127.0.0.1:3456" )
17
+ sub . connect ( "tcp://127.0.0.1:3456" )
18
+ console . log ( "Subscriber connected to tcp://127.0.0.1:3456" )
12
19
13
- pub . send ( "message" )
20
+ sub . on ( "message" , msg => {
21
+ // Handle received message...
22
+ console . log ( `Received message: ${ msg . toString ( ) } ` )
23
+ } )
14
24
15
- sub . on ( "message" , msg => {
16
- // Handle received message...
25
+ pub . send ( "message" )
17
26
} )
18
- } )
27
+
28
+ if ( process . env . CI ) {
29
+ // exit after 1 second in CI environment
30
+ setTimeout ( ( ) => {
31
+ process . exit ( 0 )
32
+ } , 2000 )
33
+ }
34
+ }
35
+
36
+ main ( )
You can’t perform that action at this time.
0 commit comments