Skip to content

Commit 6567454

Browse files
committed
more consistent print method for unresolved values. rc4
1 parent 916b8d7 commit 6567454

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

R/nano.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ print.sendAio <- function(x, ...) {
283283
#'
284284
print.unresolvedValue <- function(x, ...) {
285285

286-
cat("< unresolved: logi NA >\n", file = stdout())
286+
cat("'unresolved' logi NA\n", file = stdout())
287287
invisible(x)
288288

289289
}

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Auxiliary function `unresolved()` may be used in control flow statements to perf
226226
227227
msg <- recv_aio(s2)
228228
229-
# unresolved() queries for resolution itself so no need to use it again within the while clause
229+
# unresolved() queries for resolution itself so no need to use it again within the while loop
230230
while (unresolved(msg)) {
231231
# do stuff before checking resolution again
232232
send_aio(s1, "resolved")

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ msg
244244
#> - $data for message data
245245
#> - $raw for raw message
246246
msg$data
247-
#> < unresolved: logi NA >
247+
#> 'unresolved' logi NA
248248
```
249249

250250
For a ‘sendAio’ object, the result is stored at `$result`.
@@ -290,7 +290,7 @@ Aio to resolve, as the example below demonstrates.
290290
``` r
291291
msg <- recv_aio(s2)
292292

293-
# unresolved() queries for resolution itself so no need to use it again within the while clause
293+
# unresolved() queries for resolution itself so no need to use it again within the while loop
294294
while (unresolved(msg)) {
295295
# do stuff before checking resolution again
296296
send_aio(s1, "resolved")
@@ -369,7 +369,7 @@ aio
369369
#> < recvAio >
370370
#> - $data for message data
371371
aio$data |> str()
372-
#> num [1:100000000] 0.0464 1.2575 1.8635 0.9356 -0.9033 ...
372+
#> num [1:100000000] -1.195 0.322 -0.96 -0.25 -1.281 ...
373373
```
374374

375375
As `call_aio()` is blocking and will wait for completion, an alternative
@@ -404,37 +404,37 @@ an environment variable `NANONEXT_LOG`.
404404

405405
``` r
406406
logging(level = "info")
407-
#> 2022-03-09 18:36:44 [ log level ] set to: info
407+
#> 2022-03-09 19:58:51 [ log level ] set to: info
408408

409409
pub <- socket("pub", listen = "inproc://nanobroadcast")
410-
#> 2022-03-09 18:36:44 [ sock open ] id: 9 | protocol: pub
411-
#> 2022-03-09 18:36:44 [ list start ] sock: 9 | url: inproc://nanobroadcast
410+
#> 2022-03-09 19:58:51 [ sock open ] id: 9 | protocol: pub
411+
#> 2022-03-09 19:58:51 [ list start ] sock: 9 | url: inproc://nanobroadcast
412412
sub <- socket("sub", dial = "inproc://nanobroadcast")
413-
#> 2022-03-09 18:36:44 [ sock open ] id: 10 | protocol: sub
414-
#> 2022-03-09 18:36:44 [ dial start ] sock: 10 | url: inproc://nanobroadcast
413+
#> 2022-03-09 19:58:51 [ sock open ] id: 10 | protocol: sub
414+
#> 2022-03-09 19:58:51 [ dial start ] sock: 10 | url: inproc://nanobroadcast
415415

416416
sub |> subscribe(topic = "examples")
417-
#> 2022-03-09 18:36:44 [ subscribe ] sock: 10 | topic: examples
417+
#> 2022-03-09 19:58:51 [ subscribe ] sock: 10 | topic: examples
418418
pub |> send(c("examples", "this is an example"), mode = "raw", echo = FALSE)
419419
sub |> recv(mode = "character", keep.raw = FALSE)
420420
#> [1] "examples" "this is an example"
421421

422422
pub |> send(c("other", "this other topic will not be received"), mode = "raw", echo = FALSE)
423423
sub |> recv(mode = "character", keep.raw = FALSE)
424-
#> 2022-03-09 18:36:44 [ 8 ] Try again
424+
#> 2022-03-09 19:58:51 [ 8 ] Try again
425425

426426
# specify NULL to subscribe to ALL topics
427427
sub |> subscribe(topic = NULL)
428-
#> 2022-03-09 18:36:44 [ subscribe ] sock: 10 | topic: ALL
428+
#> 2022-03-09 19:58:51 [ subscribe ] sock: 10 | topic: ALL
429429
pub |> send(c("newTopic", "this is a new topic"), mode = "raw", echo = FALSE)
430430
sub |> recv("character", keep.raw = FALSE)
431431
#> [1] "newTopic" "this is a new topic"
432432

433433
sub |> unsubscribe(topic = NULL)
434-
#> 2022-03-09 18:36:44 [ unsubscribe ] sock: 10 | topic: ALL
434+
#> 2022-03-09 19:58:51 [ unsubscribe ] sock: 10 | topic: ALL
435435
pub |> send(c("newTopic", "this topic will now not be received"), mode = "raw", echo = FALSE)
436436
sub |> recv("character", keep.raw = FALSE)
437-
#> 2022-03-09 18:36:44 [ 8 ] Try again
437+
#> 2022-03-09 19:58:51 [ 8 ] Try again
438438

439439
# however the topics explicitly subscribed to are still received
440440
pub |> send(c("examples", "this example will still be received"), mode = "raw", echo = FALSE)
@@ -443,7 +443,7 @@ sub |> recv(mode = "character", keep.raw = FALSE)
443443

444444
# set logging level back to the default of errors only
445445
logging(level = "error")
446-
#> 2022-03-09 18:36:44 [ log level ] set to: error
446+
#> 2022-03-09 19:58:51 [ log level ] set to: error
447447

448448
close(pub)
449449
close(sub)
@@ -489,12 +489,12 @@ res2 |> recv(keep.raw = FALSE)
489489
aio1$data
490490
#> [1] "res1"
491491
aio2$data
492-
#> < unresolved: logi NA >
492+
#> 'unresolved' logi NA
493493

494494
# after the survey expires, the second resolves into a timeout error
495495
Sys.sleep(0.5)
496496
aio2$data
497-
#> 2022-03-09 18:36:44 [ 5 ] Timed out
497+
#> 2022-03-09 19:58:52 [ 5 ] Timed out
498498
#> 'errorValue' int 5
499499

500500
close(sur)
@@ -520,11 +520,11 @@ ncurl("http://httpbin.org/headers")
520520
#> [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
521521
#> [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
522522
#> [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
523-
#> [76] 2d 36 32 32 38 66 33 62 64 2d 31 66 33 39 30 32 33 35 37 65 61 31 38 34 61
524-
#> [101] 35 33 32 30 62 30 38 64 38 22 0a 20 20 7d 0a 7d 0a
523+
#> [76] 2d 36 32 32 39 30 36 66 63 2d 31 63 66 62 33 33 61 30 31 62 30 37 65 30 61
524+
#> [101] 38 33 30 66 37 39 63 39 39 22 0a 20 20 7d 0a 7d 0a
525525
#>
526526
#> $data
527-
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6228f3bd-1f3902357ea184a5320b08d8\"\n }\n}\n"
527+
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-622906fc-1cfb33a01b07e0a830f79c99\"\n }\n}\n"
528528
```
529529

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

0 commit comments

Comments
 (0)