File tree Expand file tree Collapse file tree 9 files changed +48
-10
lines changed Expand file tree Collapse file tree 9 files changed +48
-10
lines changed Original file line number Diff line number Diff line change 1+ if ( process . env . CI ) {
2+ // exit after 1 second in CI environment
3+ setTimeout ( ( ) => {
4+ process . exit ( 0 )
5+ } , 1000 )
6+ }
7+
8+ /* eslint-disable import/no-unassigned-import */
9+ import "./publisher"
10+ import "./subscriber"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ async function run() {
66 await sock . bind ( "tcp://127.0.0.1:3000" )
77 console . log ( "Publisher bound to port 3000" )
88
9+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
910 while ( true ) {
1011 console . log ( "sending a multipart message envelope" )
1112 await sock . send ( [ "kitty cats" , "meow!" ] )
@@ -15,4 +16,4 @@ async function run() {
1516 }
1617}
1718
18- run ( )
19+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ async function run() {
1717 }
1818}
1919
20- run ( )
20+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change 1+ if ( process . env . CI ) {
2+ // exit after 1 second in CI environment
3+ setTimeout ( ( ) => {
4+ process . exit ( 0 )
5+ } , 1000 )
6+ }
7+
8+ /* eslint-disable import/no-unassigned-import */
9+ import "./producer"
10+ import "./worker"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ async function run() {
66 await sock . bind ( "tcp://127.0.0.1:3000" )
77 console . log ( "Producer bound to port 3000" )
88
9+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
910 while ( true ) {
1011 await sock . send ( "some work" )
1112 await new Promise ( resolve => {
@@ -14,4 +15,4 @@ async function run() {
1415 }
1516}
1617
17- run ( )
18+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ async function run() {
1111 }
1212}
1313
14- run ( )
14+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -6,10 +6,11 @@ async function run() {
66 sock . connect ( "tcp://127.0.0.1:3000" )
77 console . log ( "Producer bound to port 3000" )
88
9- await sock . send ( "4" )
10- const [ result ] = await sock . receive ( )
9+ await sock . send ( 4 )
10+ console . log ( "Request a calculation for 4" )
1111
12- console . log ( result )
12+ const [ result ] = await sock . receive ( )
13+ console . log ( `Received result: ${ result } ` )
1314}
1415
15- run ( )
16+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change 1+ if ( process . env . CI ) {
2+ // exit after 1 second in CI environment
3+ setTimeout ( ( ) => {
4+ process . exit ( 0 )
5+ } , 1000 )
6+ }
7+
8+ /* eslint-disable import/no-unassigned-import */
9+ import "./client"
10+ import "./server"
Original file line number Diff line number Diff line change @@ -6,8 +6,13 @@ async function run() {
66 await sock . bind ( "tcp://127.0.0.1:3000" )
77
88 for await ( const [ msg ] of sock ) {
9- await sock . send ( ( 2 * parseInt ( msg . toString ( ) , 10 ) ) . toString ( ) )
9+ // parse the message as a number
10+ const value = parseInt ( msg . toString ( ) , 10 )
11+
12+ // calculate the result and send it back to the client
13+ const result = 2 * value
14+ await sock . send ( result )
1015 }
1116}
1217
13- run ( )
18+ run ( ) . catch ( console . error )
You can’t perform that action at this time.
0 commit comments