Skip to content

Commit 005915b

Browse files
committed
documentation updates + bus as default protocol
1 parent 063a8e6 commit 005915b

File tree

12 files changed

+112
-112
lines changed

12 files changed

+112
-112
lines changed

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
#### Updates
1010

1111
* Protocol-specific helpers `subscribe()`, `unsubscribe()`, and `survey_time()` gain nanoContext methods.
12+
* Default protocol is now 'bus' when opening a new Socket or nano Object - the choices are now ordered more logically.
1213
* Closing a stream now strips all attributes on the object rendering it a nil external pointer - this is for safety, eliminating a potential crash if attempting to re-use a closed stream.
1314
* For receives, if an error occurs in unserialisation or data conversion (e.g. mode was incorrectly specified), the received raw vector is now available at both `$raw` and `$data` if `keep.raw = TRUE`.
1415
* Setting 'NANONEXT_TLS=1' now allows the downloaded NNG library to be built against a system mbedtls installation.
15-
* Setting 'NANONEXT_ARM' is no longer required on platforms such as Raspberry Pi - the package configure script should now detect platforms that require the libatomic linker flag to be set automatically.
16+
* Setting 'NANONEXT_ARM' is no longer required on platforms such as Raspberry Pi - the package configure script now detects platforms requiring the libatomic linker flag automatically.
1617
* Deprecated `send_ctx()`, `recv_ctx()` and logging removed.
1718
* All-round internal performance optimisations.
1819

R/docs.R

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77
#' For an authoritative guide please refer to the online documentation for
88
#' the NNG library at <https://nng.nanomsg.org/man/>.
99
#'
10-
#' @section Pair (two-way radio):
11-
#'
12-
#' [protocol, pair] The pair protocol implements a peer-to-peer pattern,
13-
#' where relationships between peers are one-to-one. Only one peer may be
14-
#' connected to another peer at a time, but both may speak freely.
15-
#'
16-
#' Normally, this pattern will block when attempting to send a message
17-
#' if no peer is able to receive the message.
18-
#'
19-
#' @section Bus (routing):
10+
#' @section Bus (mesh networks):
2011
#'
2112
#' [protocol, bus] The bus protocol is useful for routing applications or for
2213
#' building mesh networks where every peer is connected to every other peer.
@@ -37,24 +28,16 @@
3728
#' block; instead if the message cannot be delivered for any reason it is
3829
#' discarded.
3930
#'
40-
#' @section Request/Reply (I ask, you answer):
41-
#'
42-
#' In a request/reply pattern, a requester sends a message to one replier,
43-
#' who is expected to reply with a single answer. This is used for
44-
#' synchronous communications, for example remote procedure calls (RPCs).
45-
#'
46-
#' The request is resent automatically if no reply arrives, until a reply is
47-
#' received or the request times out.
31+
#' @section Pair (two-way radio):
4832
#'
49-
#' [protocol, req] The req protocol is one half of a request/reply pattern.
50-
#' This socket may be used to send messages (requests), and then to receive
51-
#' replies. Generally a reply can only be received after sending a request.
33+
#' [protocol, pair] The pair protocol implements a peer-to-peer pattern,
34+
#' where relationships between peers are one-to-one. Only one peer may be
35+
#' connected to another peer at a time, but both may speak freely.
5236
#'
53-
#' [protocol, rep] The rep protocol is one half of a request/reply pattern.
54-
#' This socket may be used to receive messages (requests), and then to send
55-
#' replies. Generally a reply can only be sent after receiving a request.
37+
#' Normally, this pattern will block when attempting to send a message
38+
#' if no peer is able to receive the message.
5639
#'
57-
#' @section Pipeline (one-way pipe):
40+
#' @section Push/Pull (one-way pipeline):
5841
#'
5942
#' In the pipeline pattern, pushers distribute messages to pullers, hence
6043
#' useful for solving producer/consumer problems.
@@ -84,7 +67,24 @@
8467
#' pattern. This socket may be used to receive messages, but is unable to
8568
#' send them.
8669
#'
87-
#' @section Survey (everyone votes):
70+
#' @section Request/Reply (RPC):
71+
#'
72+
#' In a request/reply pattern, a requester sends a message to one replier,
73+
#' who is expected to reply with a single answer. This is used for
74+
#' synchronous communications, for example remote procedure calls (RPCs).
75+
#'
76+
#' The request is resent automatically if no reply arrives, until a reply is
77+
#' received or the request times out.
78+
#'
79+
#' [protocol, req] The req protocol is one half of a request/reply pattern.
80+
#' This socket may be used to send messages (requests), and then to receive
81+
#' replies. Generally a reply can only be received after sending a request.
82+
#'
83+
#' [protocol, rep] The rep protocol is one half of a request/reply pattern.
84+
#' This socket may be used to receive messages (requests), and then to send
85+
#' replies. Generally a reply can only be sent after receiving a request.
86+
#'
87+
#' @section Surveyor/Respondent (voting & service discovery):
8888
#'
8989
#' In a survey pattern, a surveyor sends a survey, which is broadcast to all
9090
#' peer respondents. The respondents then have a chance to reply (but are

R/nano.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@
5151
#'
5252
#' @export
5353
#'
54-
nano <- function(protocol = c("pair", "bus", "req", "rep", "push", "pull",
55-
"pub", "sub", "surveyor", "respondent"),
54+
nano <- function(protocol = c("bus", "pair", "push", "pull", "pub", "sub",
55+
"req", "rep", "surveyor", "respondent"),
5656
dial = NULL,
5757
listen = NULL,
5858
autostart = TRUE) {
5959

6060
protocol <- match.arg(protocol)
61-
6261
nano <- `class<-`(new.env(hash = FALSE), "nanoObject")
6362
socket <- socket(protocol)
6463
makeActiveBinding(sym = "socket", fun = function(x) socket, env = nano)

R/ncurl.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#' @param url the URL address.
88
#' @param async [default FALSE] logical value whether to perform actions async.
99
#' @param convert [default TRUE] logical value whether to attempt conversion of
10-
#' the received raw bytes to a character vetor.
10+
#' the received raw bytes to a character vector.
1111
#' @param method (optional) the HTTP method (defaults to 'GET' if not specified).
1212
#' @param headers (optional) a named list or character vector specifying the
1313
#' HTTP request headers e.g. \code{list(`Content-Type` = "text/plain")} or

R/socket.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#' outgoing connection) or listen (accept an incoming connection) at an
77
#' address.
88
#'
9-
#' @param protocol [default 'pair'] choose protocol - 'pair', 'bus', 'req',
10-
#' 'rep', 'push', 'pull', 'pub', 'sub', 'surveyor', or 'respondent' - see
9+
#' @param protocol [default 'bus'] choose protocol - 'bus', 'pair', 'push',
10+
#' 'pull', 'pub', 'sub', 'req', 'rep', 'surveyor', or 'respondent' - see
1111
#' \link{protocols}.
1212
#' @param dial (optional) a URL to dial, specifying the transport and address as
1313
#' a character string e.g. 'inproc://anyvalue' or 'tcp://127.0.0.1:5555'
@@ -40,12 +40,12 @@
4040
#'
4141
#' The following Scalability Protocols (communication patterns) are implemented:
4242
#' \itemize{
43+
#' \item{Bus (mesh networks) - protocol: 'bus'}
4344
#' \item{Pair (two-way radio) - protocol: 'pair'}
44-
#' \item{Bus (routing) - protocol: 'bus'}
4545
#' \item{Pipeline (one-way pipe) - protocol: 'push', 'pull'}
46-
#' \item{Request/Reply (I ask, you answer) - protocol: 'req', 'rep'}
4746
#' \item{Publisher/Subscriber (topics & broadcast) - protocol: 'pub', 'sub'}
48-
#' \item{Survey (everyone votes) - protocol: 'surveyor', 'respondent'}
47+
#' \item{Request/Reply (RPC) - protocol: 'req', 'rep'}
48+
#' \item{Survey (voting & service discovery) - protocol: 'surveyor', 'respondent'}
4949
#' }
5050
#'
5151
#' Please see \link{protocols} for further documentation.
@@ -57,14 +57,14 @@
5757
#'
5858
#' @export
5959
#'
60-
socket <- function(protocol = c("pair", "bus", "req", "rep", "push", "pull",
61-
"pub", "sub", "surveyor", "respondent"),
60+
socket <- function(protocol = c("bus", "pair", "push", "pull", "pub", "sub",
61+
"req", "rep", "surveyor", "respondent"),
6262
dial = NULL,
6363
listen = NULL,
6464
autostart = TRUE) {
6565

66-
protocol <- match.arg2(protocol, c("pair", "bus", "req", "rep", "push", "pull",
67-
"pub", "sub", "surveyor", "respondent"))
66+
protocol <- match.arg2(protocol, c("bus", "pair", "push", "pull", "pub", "sub",
67+
"req", "rep", "surveyor", "respondent"))
6868
sock <- .Call(rnng_protocol_open, protocol)
6969
is.integer(sock) && return(sock)
7070
if (!missing(dial)) dial(sock, url = dial, autostart = autostart)

README.Rmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Designed for performance and reliability, the NNG library is written in C and {n
2828

2929
Implemented scalability protocols:
3030

31-
- Bus (routing)
31+
- Bus (mesh networks)
3232
- Pair (two-way radio)
33-
- Pipeline (one-way pipe)
33+
- Push/Pull (one-way pipeline)
3434
- Publisher/Subscriber (topics & broadcast)
35-
- Request/Reply (I ask, you answer)
36-
- Survey (everyone votes)
35+
- Request/Reply (RPC)
36+
- Surveyor/Respondent (voting & service discovery)
3737

3838
Supported transports:
3939

@@ -42,7 +42,7 @@ Supported transports:
4242
- TCP (IPv4 or IPv6)
4343
- WebSocket
4444

45-
Provided web tools:
45+
Web tools:
4646

4747
- ncurl - (async) http(s) client
4848
- stream - secure websockets client (and generic low-level socket interface)
@@ -56,7 +56,7 @@ Provided web tools:
5656
4. [Async and Concurrency](#async-and-concurrency)
5757
5. [RPC and Distributed Computing](#rpc-and-distributed-computing)
5858
6. [Publisher / Subscriber Model](#publisher-subscriber-model)
59-
7. [Surveyor / Repondent Model](#surveyor-respondent-model)
59+
7. [Surveyor / Respondent Model](#surveyor-respondent-model)
6060
8. [ncurl: (Async) HTTP Client](#ncurl-async-http-client)
6161
9. [stream: Websocket Client](#stream-websocket-client)
6262
10. [Building from source](#building-from-source)

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ spanning the globe.
3030

3131
Implemented scalability protocols:
3232

33-
- Bus (routing)
33+
- Bus (mesh networks)
3434
- Pair (two-way radio)
35-
- Pipeline (one-way pipe)
35+
- Push/Pull (one-way pipeline)
3636
- Publisher/Subscriber (topics & broadcast)
37-
- Request/Reply (I ask, you answer)
38-
- Survey (everyone votes)
37+
- Request/Reply (RPC)
38+
- Surveyor/Respondent (voting & service discovery)
3939

4040
Supported transports:
4141

@@ -44,7 +44,7 @@ Supported transports:
4444
- TCP (IPv4 or IPv6)
4545
- WebSocket
4646

47-
Provided web tools:
47+
Web tools:
4848

4949
- ncurl - (async) http(s) client
5050
- stream - secure websockets client (and generic low-level socket
@@ -59,7 +59,7 @@ Provided web tools:
5959
4. [Async and Concurrency](#async-and-concurrency)
6060
5. [RPC and Distributed Computing](#rpc-and-distributed-computing)
6161
6. [Publisher / Subscriber Model](#publisher-subscriber-model)
62-
7. [Surveyor / Repondent Model](#surveyor-respondent-model)
62+
7. [Surveyor / Respondent Model](#surveyor-respondent-model)
6363
8. [ncurl: (Async) HTTP Client](#ncurl-async-http-client)
6464
9. [stream: Websocket Client](#stream-websocket-client)
6565
10. [Building from source](#building-from-source)
@@ -395,7 +395,7 @@ aio
395395
#> < recvAio >
396396
#> - $data for message data
397397
aio$data |> str()
398-
#> num [1:100000000] -1.074 0.245 0.744 -0.502 -1.666 ...
398+
#> num [1:100000000] 1.5004 -0.1919 -1.5241 0.9783 0.0144 ...
399399
```
400400

401401
As `call_aio()` is blocking and will wait for completion, an alternative
@@ -547,11 +547,11 @@ ncurl("http://httpbin.org/headers")
547547
#> [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
548548
#> [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
549549
#> [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
550-
#> [76] 2d 36 32 37 37 61 32 61 32 2d 34 39 36 62 38 32 38 61 34 38 63 35 65 61 66
551-
#> [101] 33 35 38 66 33 37 65 31 34 22 0a 20 20 7d 0a 7d 0a
550+
#> [76] 2d 36 32 37 38 32 66 61 64 2d 37 30 63 35 63 31 61 30 37 39 63 66 62 66 32
551+
#> [101] 31 37 36 65 33 34 30 65 65 22 0a 20 20 7d 0a 7d 0a
552552
#>
553553
#> $data
554-
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6277a2a2-496b828a48c5eaf358f37e14\"\n }\n}\n"
554+
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-62782fad-70c5c1a079cfbf2176e340ee\"\n }\n}\n"
555555
```
556556

557557
For advanced use, supports additional HTTP methods such as POST or PUT.
@@ -567,7 +567,7 @@ res
567567
#> - $raw for raw message
568568

569569
call_aio(res)$data
570-
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6277a2a2-6ae6efe31d378db911a099f5\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"78.145.225.121\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
570+
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-62782fad-7472b2c32d5af7603e86ae7d\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"78.145.225.121\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
571571
```
572572

573573
In this respect, it may be used as a performant and lightweight method
@@ -597,10 +597,10 @@ s
597597
#> - textframes: TRUE
598598

599599
s |> recv(keep.raw = FALSE)
600-
#> [1] "{\"e\":\"kline\",\"E\":1652007590579,\"s\":\"BTCUSDT\",\"k\":{\"t\":1652007540000,\"T\":1652007599999,\"s\":\"BTCUSDT\",\"i\":\"1m\",\"f\":1351258350,\"L\":1351258570,\"o\":\"34718.38000000\",\"c\":\"34726.74000000\",\"h\":\"34726.74000000\",\"l\":\"34717.06000000\",\"v\":\"3.78973000\",\"n\":221,\"x\":false,\"q\":\"131577.38153510\",\"V\":\"2.16208000\",\"Q\":\"75065.38564240\",\"B\":\"0\"}}"
600+
#> [1] "{\"e\":\"kline\",\"E\":1652043696064,\"s\":\"BTCUSDT\",\"k\":{\"t\":1652043660000,\"T\":1652043719999,\"s\":\"BTCUSDT\",\"i\":\"1m\",\"f\":1351814911,\"L\":1351815351,\"o\":\"34253.08000000\",\"c\":\"34279.21000000\",\"h\":\"34285.51000000\",\"l\":\"34253.07000000\",\"v\":\"21.53329000\",\"n\":441,\"x\":false,\"q\":\"737928.59980930\",\"V\":\"15.55859000\",\"Q\":\"533152.23838480\",\"B\":\"0\"}}"
601601

602602
s |> recv(keep.raw = FALSE)
603-
#> [1] "{\"e\":\"kline\",\"E\":1652007592588,\"s\":\"BTCUSDT\",\"k\":{\"t\":1652007540000,\"T\":1652007599999,\"s\":\"BTCUSDT\",\"i\":\"1m\",\"f\":1351258350,\"L\":1351258593,\"o\":\"34718.38000000\",\"c\":\"34729.58000000\",\"h\":\"34729.58000000\",\"l\":\"34717.06000000\",\"v\":\"4.01301000\",\"n\":244,\"x\":false,\"q\":\"139331.29327650\",\"V\":\"2.27211000\",\"Q\":\"78886.44058120\",\"B\":\"0\"}}"
603+
#> [1] "{\"e\":\"kline\",\"E\":1652043698106,\"s\":\"BTCUSDT\",\"k\":{\"t\":1652043660000,\"T\":1652043719999,\"s\":\"BTCUSDT\",\"i\":\"1m\",\"f\":1351814911,\"L\":1351815367,\"o\":\"34253.08000000\",\"c\":\"34281.51000000\",\"h\":\"34285.51000000\",\"l\":\"34253.07000000\",\"v\":\"21.61695000\",\"n\":457,\"x\":false,\"q\":\"740796.49099100\",\"V\":\"15.64225000\",\"Q\":\"536020.12956650\",\"B\":\"0\"}}"
604604

605605
close(s)
606606
```

man/nano.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ncurl.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/protocols.Rd

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)