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
@@ -2,22 +2,22 @@
2
2
3
3
#### New Features
4
4
5
-
* Aio values `$result`, `$raw` and `$data` now resolve without requiring `call_aio()`. Access the values directly and an 'unresolved' logical NA will be returned if the Aio operation is yet to complete.
5
+
* Aio values `$result`, `$data` and `$raw` now resolve without requiring `call_aio()`. Access the values directly and an 'unresolved' logical NA will be returned if the Aio operation is yet to complete.
6
6
*`unresolved()` added as an auxiliary function to query whether an Aio is unresolved, for use in control flow statements.
7
7
* Integer error values generated by receive functions are now classed 'errorValue'. `is_error_value()` helper function included.
8
8
*`is_nul_byte()` added as a helper function for request/reply setups.
9
9
*`survey_time()` added as a convenience function for surveyor/respondent patterns.
10
-
*`logging()` function to specify a global package logging level - 'error' or 'info'. Automatically polls the environment variable 'NANONEXT_LOG' on package load and then each time `logging(level = "check")` is called, allowing this to be set externally.
10
+
*`logging()` function to specify a global package logging level - 'error' or 'info'. Automatically checks the environment variable 'NANONEXT_LOG' on package load and then each time `logging(level = "check")` is called.
11
11
*`ncurl()` adds a '...' argument. Support for HTTP methods other than GET.
12
12
13
13
#### Updates
14
14
15
+
*`listen()` and `dial()` now return (invisible) zero rather than NULL upon success for consistency with other functions.
16
+
* Options documentation entry renamed to `opts` to avoid clash with base R 'options'.
15
17
* Common format for NNG errors and informational events now starts with a timestamp for easier logging.
16
-
*`listen()` and `dial()` now return (invisible) zero rather than NULL upon success to better align with similar functions.
17
18
* Allows setting the environment variable 'NANONEXT_ARM' prior to package installation
18
19
+ Fixes installation issues on certain ARM architectures
19
20
* More streamlined NNG build process eliminating unused options.
20
-
* Options documentation entry renamed to `opts` to avoid clash with base R 'options'.
21
21
* Removes experimental `nng_timer()` utility as a non-essential function.
22
22
* Deprecated functions 'send_vec' and 'recv_vec' removed.
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library providing high-performance scalability protocols, implementing a cross-platform standard for messaging and communications. Serves as a concurrency framework that can be used for building distributed applications.
24
+
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library providing high-performance scalability protocols, implementing a cross-platform standard for messaging and communications. Leveraging asynchronous execution, serves as a concurrency framework for building distributed applications.
25
25
26
26
Designed for performance and reliability, the NNG library is written in C and {nanonext} is a lightweight wrapper depending on no other packages. Provides the interface for code and processes to communicate with each other - receive data generated in Python, perform analysis in R, and send results to a C++ program – all on the same computer or on networks spanning the globe.
27
27
@@ -174,7 +174,7 @@ n$recv(mode = "double")
174
174
175
175
### Async and Concurrency
176
176
177
-
{nanonext} implements true async send and receive, leveraging NNG as a massively-scalable concurrency framework.
177
+
{nanonext} implements true async send and receive, leveraging NNG as a massively-scaleable concurrency framework.
178
178
179
179
`send_aio()` and `recv_aio()` functions return immediately but perform their operations async.
For a 'sendAio' object, the result is stored at `$result`. An exit code of 0 denotes a successful send.
189
-
190
-
- send is successful as long as the message has been accepted by the socket for sending
191
-
- the message may be buffered within the system
192
-
- for acknowledgement of receipt, an RPC setup is required (see next section)
188
+
For a 'sendAio' object, the result is stored at `$result`.
193
189
194
190
```{r async2}
195
191
196
192
res <- send_aio(s1, data.frame(a = 1, b = 2))
193
+
res
197
194
res$result
198
195
196
+
# an exit code of 0 denotes a successful send
197
+
# note: the send is successful as long as the message has been accepted by the socket for sending
198
+
# the message itself may still be buffered within the system
199
+
199
200
```
200
201
201
202
For a 'recvAio' object, the message is stored at `$data`, and the raw message at `$raw` (if kept).
202
203
203
204
```{r async3}
204
205
205
206
msg <- recv_aio(s2)
207
+
msg
206
208
msg$data
207
209
msg$raw
208
210
209
211
```
210
212
211
-
If the async operation is yet to complete, an 'unresolved' logical NA will be returned. In the below example an async receive is requested, but no mesages are waiting (yet to be sent).
213
+
If the async operation is yet to complete, an 'unresolved' logical NA value will be returned.
212
214
213
215
```{r async4}
214
216
217
+
# an async receive is requested, but no mesages are waiting (yet to be sent)
218
+
215
219
msg <- recv_aio(s2)
216
220
msg$data
217
221
218
222
```
219
223
220
-
For use in control flow statements, `unresolved` can be used. Note that calling this function queries for resolution itself and may cause a previously unresolved Aio to resolve.
224
+
Auxiliary function `unresolved()` can be used in control flow statements.
221
225
222
226
```{r async5}
223
227
224
-
# unresolved() already queries for resolution so no need for it again within the while clause
228
+
# unresolved() queries for resolution itself so no need to use it again within the while clause
225
229
226
230
while (unresolved(msg)) {
227
-
# do stuff here before checking resolution again
231
+
# do stuff before checking resolution again
228
232
send_aio(s1, "resolved")
233
+
cat("unresolved")
229
234
}
230
235
231
236
msg$data
@@ -254,7 +259,7 @@ close(s2)
254
259
255
260
Can be used to perform computationally-expensive calculations or I/O-bound operations such as writing large amounts of data to disk in a separate 'server' process running concurrently.
256
261
257
-
Server process: `reply()` will wait for a message and apply a function, in this case `rnorm()`, before sending back the result
262
+
Server process: `reply()` will wait for a message and apply a function, in this case `rnorm()`, before sending back the result.
258
263
259
264
```{r rpcserver, eval=FALSE}
260
265
@@ -294,9 +299,11 @@ str(aio$data)
294
299
295
300
```
296
301
302
+
As `call_aio()` is blocking and will wait for completion, an alternative is to query `aio$data` directly. This will return an 'unresolved' logical NA value if the calculation is yet to complete.
303
+
297
304
In this example the calculation is returned, but other operations may reside entirely on the server side, for example writing data to disk.
298
305
299
-
In such a case, using `call_aio()`confirms that the operation has completed (or it will wait for completion) and calls the return value of the function, which may typically be NULL or an exit code.
306
+
In such a case, calling or querying the value confirms that the operation has completed, and provides the return value of the function, which may typically be NULL or an exit code.
300
307
301
308
The {mirai} package <https://shikokuchuo.net/mirai/> (available on CRAN) uses {nanonext} as the back-end to provide asynchronous execution of arbitrary R code using the RPC model.
302
309
@@ -353,7 +360,7 @@ close(sub)
353
360
354
361
This type of pattern is useful for applications such as service discovery.
355
362
356
-
A surveyor sends a survey, which is broadcast to all peer respondents. The respondents then have a chance to reply (but are not obliged to). The survey itself is a timed event, such that responses received after the timeout are discarded.
363
+
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.
357
364
358
365
```{r survey}
359
366
@@ -390,6 +397,8 @@ close(res2)
390
397
391
398
```
392
399
400
+
Above it can be seen that the final value resolves into a timeout, which is an integer 5 classed as 'errorValue'. All receive functions class integer error codes as 'errorValue' to be easily distinguishable from integer message values.
0 commit comments