Skip to content

Commit e41f602

Browse files
committed
update readme
1 parent 7c7d210 commit e41f602

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

README.Rmd

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,19 @@ The log level can also be set externally in production environments via an envir
319319

320320
```{r pub}
321321
322-
# set logging level to include information events ------------------------------
323322
logging(level = "info")
324323
325324
pub <- socket("pub", listen = "inproc://nanobroadcast")
326325
sub <- socket("sub", dial = "inproc://nanobroadcast")
327326
328-
# subscribing to a specific topic 'examples' -----------------------------------
329327
sub |> subscribe(topic = "examples")
330328
pub |> send(c("examples", "this is an example"), mode = "raw", echo = FALSE)
331329
sub |> recv(mode = "character", keep.raw = FALSE)
332330
333331
pub |> send(c("other", "this other topic will not be received"), mode = "raw", echo = FALSE)
334332
sub |> recv(mode = "character", keep.raw = FALSE)
335333
336-
# specify NULL to subscribe to ALL topics --------------------------------------
334+
# specify NULL to subscribe to ALL topics
337335
sub |> subscribe(topic = NULL)
338336
pub |> send(c("newTopic", "this is a new topic"), mode = "raw", echo = FALSE)
339337
sub |> recv("character", keep.raw = FALSE)
@@ -342,11 +340,11 @@ sub |> unsubscribe(topic = NULL)
342340
pub |> send(c("newTopic", "this topic will now not be received"), mode = "raw", echo = FALSE)
343341
sub |> recv("character", keep.raw = FALSE)
344342
345-
# however the topics explicitly subscribed to are still received ---------------
343+
# however the topics explicitly subscribed to are still received
346344
pub |> send(c("examples", "this example will still be received"), mode = "raw", echo = FALSE)
347345
sub |> recv(mode = "character", keep.raw = FALSE)
348346
349-
# set logging level back to the default of errors only -------------------------
347+
# set logging level back to the default of errors only
350348
logging(level = "error")
351349
352350
close(pub)
@@ -368,26 +366,26 @@ sur <- socket("surveyor", listen = "inproc://nanoservice")
368366
res1 <- socket("respondent", dial = "inproc://nanoservice")
369367
res2 <- socket("respondent", dial = "inproc://nanoservice")
370368
371-
# sur sets a survey timeout, applying to this and subsequent surveys -----------
369+
# sur sets a survey timeout, applying to this and subsequent surveys
372370
sur |> survey_time(500)
373371
374-
# sur sends a message and then requests 2 async receives -----------------------
372+
# sur sends a message and then requests 2 async receives
375373
sur |> send("service check", echo = FALSE)
376374
aio1 <- sur |> recv_aio()
377375
aio2 <- sur |> recv_aio()
378376
379-
# res1 receives the message and replies using an aio send function -------------
377+
# res1 receives the message and replies using an aio send function
380378
res1 |> recv(keep.raw = FALSE)
381379
res1 |> send_aio("res1")
382380
383-
# res2 receives the message but fails to reply ---------------------------------
381+
# res2 receives the message but fails to reply
384382
res2 |> recv(keep.raw = FALSE)
385383
386-
# checking the aio - only the first will have resolved -------------------------
384+
# checking the aio - only the first will have resolved
387385
aio1$data
388386
aio2$data
389387
390-
# after the survey expires, the second resolves into a timeout error -----------
388+
# after the survey expires, the second resolves into a timeout error
391389
Sys.sleep(0.5)
392390
aio2$data
393391

README.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ aio
365365
#> < recvAio >
366366
#> - $data for message data
367367
str(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

371371
As `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
399399
an environment variable `NANONEXT_LOG`.
400400

401401
``` r
402-
# set logging level to include information events ------------------------------
403402
logging(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

406405
pub <- 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
409408
sub <- 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' -----------------------------------
414412
sub |> 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
416414
pub |> send(c("examples", "this is an example"), mode = "raw", echo = FALSE)
417415
sub |> recv(mode = "character", keep.raw = FALSE)
418416
#> [1] "examples" "this is an example"
419417

420418
pub |> send(c("other", "this other topic will not be received"), mode = "raw", echo = FALSE)
421419
sub |> 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
425423
sub |> 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
427425
pub |> send(c("newTopic", "this is a new topic"), mode = "raw", echo = FALSE)
428426
sub |> recv("character", keep.raw = FALSE)
429427
#> [1] "newTopic" "this is a new topic"
430428

431429
sub |> 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
433431
pub |> send(c("newTopic", "this topic will now not be received"), mode = "raw", echo = FALSE)
434432
sub |> 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
438436
pub |> send(c("examples", "this example will still be received"), mode = "raw", echo = FALSE)
439437
sub |> 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
443441
logging(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

446444
close(pub)
447445
close(sub)
@@ -464,35 +462,35 @@ sur <- socket("surveyor", listen = "inproc://nanoservice")
464462
res1 <- socket("respondent", dial = "inproc://nanoservice")
465463
res2 <- 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
468466
sur |> 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
471469
sur |> send("service check", echo = FALSE)
472470
aio1 <- sur |> recv_aio()
473471
aio2 <- 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
476474
res1 |> recv(keep.raw = FALSE)
477475
#> [1] "service check"
478476
res1 |> 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
483481
res2 |> 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
487485
aio1$data
488486
#> [1] "res1"
489487
aio2$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
493491
Sys.sleep(0.5)
494492
aio2$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

498496
close(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

528526
For advanced use, supports additional HTTP methods such as POST or PUT.

0 commit comments

Comments
 (0)