File tree 9 files changed +48
-10
lines changed
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() {
6
6
await sock . bind ( "tcp://127.0.0.1:3000" )
7
7
console . log ( "Publisher bound to port 3000" )
8
8
9
+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
9
10
while ( true ) {
10
11
console . log ( "sending a multipart message envelope" )
11
12
await sock . send ( [ "kitty cats" , "meow!" ] )
@@ -15,4 +16,4 @@ async function run() {
15
16
}
16
17
}
17
18
18
- run ( )
19
+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -17,4 +17,4 @@ async function run() {
17
17
}
18
18
}
19
19
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() {
6
6
await sock . bind ( "tcp://127.0.0.1:3000" )
7
7
console . log ( "Producer bound to port 3000" )
8
8
9
+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
9
10
while ( true ) {
10
11
await sock . send ( "some work" )
11
12
await new Promise ( resolve => {
@@ -14,4 +15,4 @@ async function run() {
14
15
}
15
16
}
16
17
17
- run ( )
18
+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ async function run() {
11
11
}
12
12
}
13
13
14
- run ( )
14
+ run ( ) . catch ( console . error )
Original file line number Diff line number Diff line change @@ -6,10 +6,11 @@ async function run() {
6
6
sock . connect ( "tcp://127.0.0.1:3000" )
7
7
console . log ( "Producer bound to port 3000" )
8
8
9
- await sock . send ( "4" )
10
- const [ result ] = await sock . receive ( )
9
+ await sock . send ( 4 )
10
+ console . log ( "Request a calculation for 4" )
11
11
12
- console . log ( result )
12
+ const [ result ] = await sock . receive ( )
13
+ console . log ( `Received result: ${ result } ` )
13
14
}
14
15
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() {
6
6
await sock . bind ( "tcp://127.0.0.1:3000" )
7
7
8
8
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 )
10
15
}
11
16
}
12
17
13
- run ( )
18
+ run ( ) . catch ( console . error )
You can’t perform that action at this time.
0 commit comments