Skip to content

Commit 7509314

Browse files
committed
CRAN release 0.5.1
1 parent 5575414 commit 7509314

File tree

4 files changed

+70
-138
lines changed

4 files changed

+70
-138
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: nanonext
22
Type: Package
33
Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library
4-
Version: 0.5.0.9000
4+
Version: 0.5.1
55
Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is
66
a socket library providing high-performance scalability protocols,
77
implementing a cross-platform standard for messaging and communications.

NEWS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# nanonext 0.5.0.9000 (development)
1+
# nanonext 0.5.1
22

33
#### Updates
44

55
* Upgrades NNG library to 1.6.0 pre-release (locked to version 722bf46). This version incorporates a feature simplifying the aio implementation in nanonext.
6-
* Configure script updated to always download and build 'libnng' from source (except on Windows where pre-built libraries are downloaded). The script still attempts to detect a system 'mbedtls' library to link against.
7-
* Environment variable 'NANONEXT_SYS' introduced to permit use of a system 'libnng' install in /usr/local. Note that this is a manual setting allowing for custom NNG builds, and requires a version of NNG at least as recent as 722bf46.
8-
* Fixes a bug affecting aios (thanks @lionel- #3).
6+
* Configure script updated to always download and build 'libnng' from source (except on Windows where pre-built libraries are downloaded). The script still attempts to detect a system 'libmbedtls' library to link against.
7+
* Environment variable 'NANONEXT_SYS' introduced to permit use of a system 'libnng' install in `/usr/local`. Note that this is a manual setting allowing for custom NNG builds, and requires a version of NNG at least as recent as 722bf46.
8+
* Fixes a bug involving the `unresolvedValue` returned by Aios (thanks @lionel- #3).
99

1010
# nanonext 0.5.0
1111

README.Rmd

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ recv(socket2)
142142

143143
### Cross-language Exchange
144144

145-
{nanonext} provides a fast and reliable data interface between different programming languages where NNG has a binding, including C, C++, Java, Python, Go, Rust etc.
145+
{nanonext} provides a fast and reliable data interface between different programming languages where NNG has an implementation, including C, C++, Java, Python, Go, Rust etc.
146146

147147
The following example demonstrates the exchange of numerical data between R and Python (NumPy), two of the most commonly-used languages for data science and machine learning.
148148

@@ -190,7 +190,6 @@ n$recv(mode = "double")
190190
{nanonext} implements true async send and receive, leveraging NNG as a massively-scaleable concurrency framework.
191191

192192
```{r async}
193-
194193
s1 <- socket("pair", listen = "inproc://nano")
195194
s2 <- socket("pair", dial = "inproc://nano")
196195
@@ -201,7 +200,6 @@ s2 <- socket("pair", dial = "inproc://nano")
201200
An 'Aio' object returns an unresolved value whilst its asynchronous operation is ongoing, automatically resolving to a final value once complete.
202201

203202
```{r async4}
204-
205203
# an async receive is requested, but no messages are waiting (yet to be sent)
206204
msg <- recv_aio(s2)
207205
msg
@@ -212,7 +210,6 @@ msg$data
212210
For a 'sendAio' object, the result is stored at `$result`.
213211

214212
```{r async2}
215-
216213
res <- send_aio(s1, data.frame(a = 1, b = 2))
217214
res
218215
res$result
@@ -226,8 +223,7 @@ res$result
226223
For a 'recvAio' object, the message is stored at `$data`, and the raw message at `$raw` (if kept).
227224

228225
```{r async3}
229-
230-
# now that a message has been sent, the 'recvAio' automatically resolves
226+
# now that a message has been sent, the 'recvAio' resolves automatically
231227
msg$data
232228
msg$raw
233229
@@ -236,7 +232,6 @@ msg$raw
236232
Auxiliary function `unresolved()` may be used in control flow statements to perform actions which depend on resolution of the Aio, both before and after. This means there is no need to actually wait (block) for an Aio to resolve, as the example below demonstrates.
237233

238234
```{r async5}
239-
240235
msg <- recv_aio(s2)
241236
242237
# unresolved() queries for resolution itself so no need to use it again within the while loop
@@ -253,7 +248,6 @@ msg$data
253248
The values may also be called explicitly using `call_aio()`. This will wait for completion of the Aio (blocking).
254249

255250
```{r async7}
256-
257251
# will wait for completion then return the resolved Aio
258252
call_aio(msg)
259253
@@ -276,7 +270,6 @@ Can be used to perform computationally-expensive calculations or I/O-bound opera
276270
[S] Server process: `reply()` will wait for a message and apply a function, in this case `rnorm()`, before sending back the result.
277271

278272
```{r rpcserver, eval=FALSE}
279-
280273
library(nanonext)
281274
rep <- socket("rep", listen = "tcp://127.0.0.1:6546")
282275
ctxp <- context(rep)
@@ -287,7 +280,6 @@ reply(ctxp, execute = rnorm, send_mode = "raw")
287280
[C] Client process: `request()` performs an async send and receive request and returns immediately with a `recvAio` object.
288281

289282
```{r rpcclient}
290-
291283
library(nanonext)
292284
req <- socket("req", dial = "tcp://127.0.0.1:6546")
293285
ctxq <- context(req)
@@ -306,7 +298,6 @@ When the result of the server calculation is required, the `recvAio` may be call
306298
The return value from the server request is then retrieved and stored in the Aio as `$data`.
307299

308300
```{r rpcclient3}
309-
310301
call_aio(aio)
311302
312303
aio
@@ -329,7 +320,6 @@ The {mirai} package <https://shikokuchuo.net/mirai/> (available on CRAN) uses {n
329320
{nanonext} fully implements NNG's pub/sub protocol as per the below example. A subscriber can subscribe to one or multiple topics broadcast by a publisher.
330321

331322
```{r pub}
332-
333323
pub <- socket("pub", listen = "inproc://nanobroadcast")
334324
sub <- socket("sub", dial = "inproc://nanobroadcast")
335325
@@ -362,7 +352,6 @@ sub |> recv(mode = "character", keep.raw = FALSE)
362352
The subscribed topic can be of any atomic type (not just character), allowing integer, double, logical, complex and raw vectors to be sent and received.
363353

364354
```{r pub2}
365-
366355
sub |> subscribe(topic = 1)
367356
pub |> send(c(1, 10, 10, 20), mode = "raw", echo = FALSE)
368357
sub |> recv(mode = "double", keep.raw = FALSE)
@@ -381,7 +370,6 @@ This type of pattern is useful for applications such as service discovery.
381370
A surveyor sends a survey, which is broadcast to all peer respondents. Respondents are then able to reply, but are not obliged to. The survey itself is a timed event, and responses received after the timeout are discarded.
382371

383372
```{r survey}
384-
385373
sur <- socket("surveyor", listen = "inproc://nanoservice")
386374
res1 <- socket("respondent", dial = "inproc://nanoservice")
387375
res2 <- socket("respondent", dial = "inproc://nanoservice")
@@ -428,15 +416,13 @@ By setting `async = TRUE`, it performs requests asynchronously, returning immedi
428416
For normal use, it takes just the URL. It can follow redirects.
429417

430418
```{r ncurl}
431-
432419
ncurl("http://httpbin.org/headers")
433420
434421
```
435422

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

438425
```{r ncurladv}
439-
440426
res <- ncurl("http://httpbin.org/post", async = TRUE, method = "POST",
441427
headers = c(`Content-Type` = "application/json", Authorization = "Bearer APIKEY"),
442428
data = '{"key": "value"}')
@@ -457,10 +443,20 @@ In this respect, it may be used as a performant and lightweight method for makin
457443
The stream interface can be used to communicate with websocket servers. Where TLS is enabled in the NNG library, connecting to secure websockets is configured automatically. The argument `textframes = TRUE` can be specified where the websocket server uses text rather than binary frames.
458444

459445
```{r stream}
460-
461-
s <- stream(dial = "wss://stream.binance.com:9443/ws/btcusdt@kline_1m", textframes = TRUE)
446+
# official demo API key used below
447+
s <- stream(dial = "wss://ws.eodhistoricaldata.com/ws/forex?api_token=OeAFFmMliFG5orCUuwAKQ8l4WWFQ67YX",
448+
textframes = TRUE)
462449
s
463450
451+
```
452+
453+
`send()` and `recv()`, as well as their asynchronous counterparts `send_aio()` and `recv_aio()` can be used on Streams in the same way as Sockets. This affords a great deal of flexibility in ingesting and processing streaming data.
454+
455+
```{r stream2}
456+
s |> recv(keep.raw = FALSE)
457+
458+
s |> send('{"action": "subscribe", "symbols": "EURUSD"}')
459+
464460
s |> recv(keep.raw = FALSE)
465461
466462
s |> recv(keep.raw = FALSE)
@@ -469,52 +465,27 @@ close(s)
469465
470466
```
471467

472-
The same API for Sockets is available for use on Streams: `send()` and `recv()`, as well as their asynchronous counterparts `send_aio()` and `recv_aio()`. This affords a great deal of flexibility in ingesting and processing streaming data.
473-
474468
[&laquo; Back to ToC](#table-of-contents)
475469

476470
### Building from source
477471

478472
#### Linux / Mac / Solaris
479473

480-
Installation from source requires the C library 'libnng' along with its development headers.
481-
482-
This is available in system package repositories as:
483-
484-
- `libnng-dev` (deb)
485-
- `nng-devel` (rpm)
486-
- `nng` (Homebrew on MacOS)
474+
Installation from source requires 'cmake'. A pre-release version of 'libnng' 1.6.0 (722bf46) is downloaded and built automatically during package installation.
487475

488-
A system installation of 'libnng' in the standard filesystem locations will be detected and used if possible.
476+
Setting `Sys.setenv(NANONEXT_SYS=1)` will cause installation to attempt use of a system 'libnng' installed in `/usr/local` instead. This allows use of a custom build of 'libnng' (722bf46 or newer).
489477

490-
Otherwise, the latest release version of 'libnng' will be downloaded and built from source automatically during package installation (note: this requires 'cmake').
478+
System 'libnng' installations are not used by default as versions currently in system repositories are not new enough to support nanonext >= 0.5.1.
491479

492480
#### Windows
493481

494-
Pre-built libraries (for i386 / x64 / x64-UCRT) are automatically downloaded during the package installation process.
482+
Pre-built 'libnng' 1.6.0 (722bf46) libraries are downloaded automatically during the package installation process.
495483

496484
#### TLS Support
497485

498-
If system installations of 'libnng' and 'libmbedtls' development headers are detected in the same location, it is assumed that NNG was built with TLS support (using Mbed TLS) and TLS support is configured appropriately.
499-
500-
Otherwise, the environment variable `Sys.setenv(NANONEXT_TLS=1)` may be set prior to installation if:
501-
502-
- system installations of 'libnng' (built with TLS support) and 'libmbedtls' are in different locations; or
503-
- there is a system installation of 'libmbedtls' but not 'libnng' - in which case nanonext will download and build the latest release of 'libnng' against this.
504-
505-
#### Development Version
506-
507-
For the development version (to become the next CRAN release), the installation behaviour changes in the following way:
508-
509-
- A specific pre-release version of 'libnng' 1.6.0 (722bf46) will be downloaded and built from source automatically during package installation (requiring 'cmake').
510-
- Windows libraries are still available pre-built (also updated to 1.6.0 pre-release).
511-
- Mbedtls is still detected automatically if installed in the standard filesystem locations, or if the `NANONEXT_TLS` environment variable is specified.
512-
513-
This is as nanonext now depends on a feature not present in prior releases of 'libnng', including those currently available in system repositories.
514-
515-
If you prefer to build your own version of 'libnng' (722bf46 or newer), specify the environment variable `Sys.setenv(NANONEXT_SYS=1)` prior to package installation:
486+
If a system installation of Mbed TLS 'libmbedtls' is detected in the standard filesystem locations, NNG will link against this and be built with TLS support.
516487

517-
- attempts to use a system 'libnng' installed in /usr/local instead of the download and build process.
488+
The environment variable `Sys.setenv(NANONEXT_TLS=1)` may also be set prior to installation to enable TLS support if 'libmbedtls' is installed in a non-standard location.
518489

519490
### Links
520491

0 commit comments

Comments
 (0)