365365# > < recvAio >
366366# > - $data for message data
367367str(aio $ data )
368- # > num [1:100000000] 1.061 0.522 -0.601 -0.63 -0.587 ...
368+ # > num [1:100000000] 1.0964 0.2245 -0.0617 -1.2121 -0.2527 ...
369369```
370370
371371As ` call_aio() ` is blocking and will wait for completion, an alternative
@@ -399,49 +399,47 @@ The log level can also be set externally in production environments via
399399an environment variable ` NANONEXT_LOG ` .
400400
401401``` r
402- # set logging level to include information events ------------------------------
403402logging(level = " info" )
404- # > 2022-03-04 14:57:58 [ log level ] set to: info
403+ # > 2022-03-04 23:52:52 [ log level ] set to: info
405404
406405pub <- socket(" pub" , listen = " inproc://nanobroadcast" )
407- # > 2022-03-04 14:57:58 [ sock open ] id: 9 | protocol: pub
408- # > 2022-03-04 14:57:58 [ list start ] sock: 9 | url: inproc://nanobroadcast
406+ # > 2022-03-04 23:52:52 [ sock open ] id: 9 | protocol: pub
407+ # > 2022-03-04 23:52:52 [ list start ] sock: 9 | url: inproc://nanobroadcast
409408sub <- socket(" sub" , dial = " inproc://nanobroadcast" )
410- # > 2022-03-04 14:57:58 [ sock open ] id: 10 | protocol: sub
411- # > 2022-03-04 14:57:58 [ dial start ] sock: 10 | url: inproc://nanobroadcast
409+ # > 2022-03-04 23:52:52 [ sock open ] id: 10 | protocol: sub
410+ # > 2022-03-04 23:52:52 [ dial start ] sock: 10 | url: inproc://nanobroadcast
412411
413- # subscribing to a specific topic 'examples' -----------------------------------
414412sub | > subscribe(topic = " examples" )
415- # > 2022-03-04 14:57:58 [ subscribe ] sock: 10 | topic: examples
413+ # > 2022-03-04 23:52:52 [ subscribe ] sock: 10 | topic: examples
416414pub | > send(c(" examples" , " this is an example" ), mode = " raw" , echo = FALSE )
417415sub | > recv(mode = " character" , keep.raw = FALSE )
418416# > [1] "examples" "this is an example"
419417
420418pub | > send(c(" other" , " this other topic will not be received" ), mode = " raw" , echo = FALSE )
421419sub | > recv(mode = " character" , keep.raw = FALSE )
422- # > 2022-03-04 14:57:58 [ 8 ] Try again
420+ # > 2022-03-04 23:52:52 [ 8 ] Try again
423421
424- # specify NULL to subscribe to ALL topics --------------------------------------
422+ # specify NULL to subscribe to ALL topics
425423sub | > subscribe(topic = NULL )
426- # > 2022-03-04 14:57:58 [ subscribe ] sock: 10 | topic: ALL
424+ # > 2022-03-04 23:52:52 [ subscribe ] sock: 10 | topic: ALL
427425pub | > send(c(" newTopic" , " this is a new topic" ), mode = " raw" , echo = FALSE )
428426sub | > recv(" character" , keep.raw = FALSE )
429427# > [1] "newTopic" "this is a new topic"
430428
431429sub | > unsubscribe(topic = NULL )
432- # > 2022-03-04 14:57:58 [ unsubscribe ] sock: 10 | topic: ALL
430+ # > 2022-03-04 23:52:52 [ unsubscribe ] sock: 10 | topic: ALL
433431pub | > send(c(" newTopic" , " this topic will now not be received" ), mode = " raw" , echo = FALSE )
434432sub | > recv(" character" , keep.raw = FALSE )
435- # > 2022-03-04 14:57:58 [ 8 ] Try again
433+ # > 2022-03-04 23:52:52 [ 8 ] Try again
436434
437- # however the topics explicitly subscribed to are still received ---------------
435+ # however the topics explicitly subscribed to are still received
438436pub | > send(c(" examples" , " this example will still be received" ), mode = " raw" , echo = FALSE )
439437sub | > recv(mode = " character" , keep.raw = FALSE )
440438# > [1] "examples" "this example will still be received"
441439
442- # set logging level back to the default of errors only -------------------------
440+ # set logging level back to the default of errors only
443441logging(level = " error" )
444- # > 2022-03-04 14:57:58 [ log level ] set to: error
442+ # > 2022-03-04 23:52:52 [ log level ] set to: error
445443
446444close(pub )
447445close(sub )
@@ -464,35 +462,35 @@ sur <- socket("surveyor", listen = "inproc://nanoservice")
464462res1 <- socket(" respondent" , dial = " inproc://nanoservice" )
465463res2 <- socket(" respondent" , dial = " inproc://nanoservice" )
466464
467- # sur sets a survey timeout, applying to this and subsequent surveys -----------
465+ # sur sets a survey timeout, applying to this and subsequent surveys
468466sur | > survey_time(500 )
469467
470- # sur sends a message and then requests 2 async receives -----------------------
468+ # sur sends a message and then requests 2 async receives
471469sur | > send(" service check" , echo = FALSE )
472470aio1 <- sur | > recv_aio()
473471aio2 <- sur | > recv_aio()
474472
475- # res1 receives the message and replies using an aio send function -------------
473+ # res1 receives the message and replies using an aio send function
476474res1 | > recv(keep.raw = FALSE )
477475# > [1] "service check"
478476res1 | > send_aio(" res1" )
479477# > < sendAio >
480478# > - $result for send result
481479
482- # res2 receives the message but fails to reply ---------------------------------
480+ # res2 receives the message but fails to reply
483481res2 | > recv(keep.raw = FALSE )
484482# > [1] "service check"
485483
486- # checking the aio - only the first will have resolved -------------------------
484+ # checking the aio - only the first will have resolved
487485aio1 $ data
488486# > [1] "res1"
489487aio2 $ data
490488# > < unresolved: logi NA >
491489
492- # after the survey expires, the second resolves into a timeout error -----------
490+ # after the survey expires, the second resolves into a timeout error
493491Sys.sleep(0.5 )
494492aio2 $ data
495- # > 2022-03-04 14:57:59 [ 5 ] Timed out
493+ # > 2022-03-04 23:52:53 [ 5 ] Timed out
496494# > 'errorValue' int 5
497495
498496close(sur )
@@ -518,11 +516,11 @@ ncurl("http://httpbin.org/headers")
518516# > [1] 7b 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20 7b 0a 20 20 20 20 22 48 6f 73
519517# > [26] 74 22 3a 20 22 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20 22
520518# > [51] 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31
521- # > [76] 2d 36 32 32 32 32 38 66 37 2d 33 33 61 61 39 66 63 64 33 32 63 38 35 36 32
522- # > [101] 61 33 65 35 32 32 64 65 35 22 0a 20 20 7d 0a 7d 0a
519+ # > [76] 2d 36 32 32 32 61 36 35 35 2d 33 31 31 32 32 33 61 39 35 35 37 35 62 36 31
520+ # > [101] 39 33 66 36 61 63 63 65 64 22 0a 20 20 7d 0a 7d 0a
523521# >
524522# > $data
525- # > [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-622228f7-33aa9fcd32c8562a3e522de5 \"\n }\n}\n"
523+ # > [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6222a655-311223a95575b6193f6acced \"\n }\n}\n"
526524```
527525
528526For advanced use, supports additional HTTP methods such as POST or PUT.
0 commit comments