You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
-
# nanonext 0.5.0.9000 (development)
1
+
# nanonext 0.5.1
2
2
3
3
#### Updates
4
4
5
5
* 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).
Copy file name to clipboardExpand all lines: README.Rmd
+20-49Lines changed: 20 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ recv(socket2)
142
142
143
143
### Cross-language Exchange
144
144
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.
146
146
147
147
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.
148
148
@@ -190,7 +190,6 @@ n$recv(mode = "double")
190
190
{nanonext} implements true async send and receive, leveraging NNG as a massively-scaleable concurrency framework.
An 'Aio' object returns an unresolved value whilst its asynchronous operation is ongoing, automatically resolving to a final value once complete.
202
201
203
202
```{r async4}
204
-
205
203
# an async receive is requested, but no messages are waiting (yet to be sent)
206
204
msg <- recv_aio(s2)
207
205
msg
@@ -212,7 +210,6 @@ msg$data
212
210
For a 'sendAio' object, the result is stored at `$result`.
213
211
214
212
```{r async2}
215
-
216
213
res <- send_aio(s1, data.frame(a = 1, b = 2))
217
214
res
218
215
res$result
@@ -226,8 +223,7 @@ res$result
226
223
For a 'recvAio' object, the message is stored at `$data`, and the raw message at `$raw` (if kept).
227
224
228
225
```{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
231
227
msg$data
232
228
msg$raw
233
229
@@ -236,7 +232,6 @@ msg$raw
236
232
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.
237
233
238
234
```{r async5}
239
-
240
235
msg <- recv_aio(s2)
241
236
242
237
# unresolved() queries for resolution itself so no need to use it again within the while loop
@@ -253,7 +248,6 @@ msg$data
253
248
The values may also be called explicitly using `call_aio()`. This will wait for completion of the Aio (blocking).
254
249
255
250
```{r async7}
256
-
257
251
# will wait for completion then return the resolved Aio
258
252
call_aio(msg)
259
253
@@ -276,7 +270,6 @@ Can be used to perform computationally-expensive calculations or I/O-bound opera
276
270
[S] Server process: `reply()` will wait for a message and apply a function, in this case `rnorm()`, before sending back the result.
@@ -306,7 +298,6 @@ When the result of the server calculation is required, the `recvAio` may be call
306
298
The return value from the server request is then retrieved and stored in the Aio as `$data`.
307
299
308
300
```{r rpcclient3}
309
-
310
301
call_aio(aio)
311
302
312
303
aio
@@ -329,7 +320,6 @@ The {mirai} package <https://shikokuchuo.net/mirai/> (available on CRAN) uses {n
329
320
{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.
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.
@@ -381,7 +370,6 @@ This type of pattern is useful for applications such as service discovery.
381
370
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.
382
371
383
372
```{r survey}
384
-
385
373
sur <- socket("surveyor", listen = "inproc://nanoservice")
@@ -457,10 +443,20 @@ In this respect, it may be used as a performant and lightweight method for makin
457
443
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.
458
444
459
445
```{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)
462
449
s
463
450
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
+
464
460
s |> recv(keep.raw = FALSE)
465
461
466
462
s |> recv(keep.raw = FALSE)
@@ -469,52 +465,27 @@ close(s)
469
465
470
466
```
471
467
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
-
474
468
[« Back to ToC](#table-of-contents)
475
469
476
470
### Building from source
477
471
478
472
#### Linux / Mac / Solaris
479
473
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.
487
475
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).
489
477
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.
491
479
492
480
#### Windows
493
481
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.
495
483
496
484
#### TLS Support
497
485
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.
516
487
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.
0 commit comments