Skip to content

Commit 7e4ebca

Browse files
committed
Re-format reference vignette
1 parent 84e38a5 commit 7e4ebca

File tree

4 files changed

+24
-92
lines changed

4 files changed

+24
-92
lines changed

README.Rmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ knitr::opts_chunk$set(
2121
[![R-universe status](https://r-lib.r-universe.dev/badges/nanonext?color=3f72af)](https://r-lib.r-universe.dev/nanonext)
2222
[![R-CMD-check](https://github.com/r-lib/nanonext/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/nanonext/actions/workflows/R-CMD-check.yaml)
2323
[![Codecov test coverage](https://codecov.io/gh/r-lib/nanonext/graph/badge.svg)](https://app.codecov.io/gh/r-lib/nanonext)
24-
[![DOI](https://zenodo.org/badge/451104675.svg)](https://doi.org/10.5281/zenodo.7903429)
2524
<!-- badges: end -->
2625

2726
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library for reliable, high-performance messaging over in-process, IPC, TCP, WebSocket and secure TLS transports. Implements 'Scalability Protocols', a standard for common communications patterns including publish/subscribe, request/reply and service discovery.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ status](https://r-lib.r-universe.dev/badges/nanonext?color=3f72af)](https://r-li
1212
[![R-CMD-check](https://github.com/r-lib/nanonext/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/nanonext/actions/workflows/R-CMD-check.yaml)
1313
[![Codecov test
1414
coverage](https://codecov.io/gh/r-lib/nanonext/graph/badge.svg)](https://app.codecov.io/gh/r-lib/nanonext)
15-
[![DOI](https://zenodo.org/badge/451104675.svg)](https://doi.org/10.5281/zenodo.7903429)
1615
<!-- badges: end -->
1716

1817
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a

dev/vignettes/_nanonext.Rmd

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,7 @@ knitr::opts_chunk$set(
1515
)
1616
```
1717

18-
### Table of Contents
19-
20-
1. [Cross-language Exchange](#cross-language-exchange)
21-
2. [Async and Concurrency](#async-and-concurrency)
22-
3. [Synchronisation Primitives](#synchronisation-primitives)
23-
4. [TLS Secure Connections](#tls-secure-connections)
24-
5. [Request / Reply Protocol](#request-reply-protocol)
25-
6. [Publisher / Subscriber Protocol](#publisher-subscriber-protocol)
26-
7. [Surveyor / Respondent Protocol](#surveyor-respondent-protocol)
27-
8. [ncurl: (Async) HTTP Client](#ncurl-async-http-client)
28-
9. [stream: Websocket Client](#stream-websocket-client)
29-
10. [Options, Serialization and Statistics](#options-serialization-and-statistics)
30-
31-
### Cross-language Exchange
18+
### 1. Cross-language Exchange
3219

3320
`nanonext` provides a fast, reliable data interface between different programming languages where NNG has an implementation, including C, C++, Java, Python, Go, and Rust.
3421

@@ -82,9 +69,7 @@ n$recv(mode = "double")
8269
n$close()
8370
```
8471

85-
[&laquo; Back to ToC](#table-of-contents)
86-
87-
### Async and Concurrency
72+
### 2. Async and Concurrency
8873

8974
`nanonext` implements true async send and receive, leveraging NNG as a massively-scalable concurrency framework.
9075

@@ -162,9 +147,7 @@ close(s2)
162147
163148
```
164149

165-
[&laquo; Back to ToC](#table-of-contents)
166-
167-
### Synchronisation Primitives
150+
### 3. Synchronisation Primitives
168151

169152
`nanonext` implements cross-platform synchronisation primitives from the NNG library, enabling synchronisation between NNG events and the main R execution thread.
170153

@@ -232,9 +215,7 @@ When `flag = TRUE` is set for pipe notifications, `wait()` returns FALSE for pip
232215

233216
This mechanism enables waiting simultaneously on multiple events while distinguishing between them. `pipe_notify()` can signal up to two condition variables per event for additional flexibility in concurrent applications.
234217

235-
[&laquo; Back to ToC](#table-of-contents)
236-
237-
### TLS Secure Connections
218+
### 4. TLS Secure Connections
238219

239220
Secure connections use NNG and Mbed TLS libraries. Enable them by:
240221

@@ -270,9 +251,7 @@ close(s)
270251
271252
```
272253

273-
[&laquo; Back to ToC](#table-of-contents)
274-
275-
### Request Reply Protocol
254+
### 5. Request Reply Protocol
276255

277256
`nanonext` implements remote procedure calls (RPC) using NNG's req/rep protocol for distributed computing. Use this for computationally-expensive calculations or I/O-bound operations in separate server processes.
278257

@@ -318,9 +297,7 @@ For server-side operations (e.g., writing to disk), calling or querying the valu
318297

319298
The [`mirai`](https://doi.org/10.5281/zenodo.7912722) package (<https://mirai.r-lib.org/>) uses `nanonext` as the back-end to provide asynchronous execution of arbitrary R code using the RPC model.
320299

321-
[&laquo; Back to ToC](#table-of-contents)
322-
323-
### Publisher Subscriber Protocol
300+
### 6. Publisher Subscriber Protocol
324301

325302
`nanonext` implements NNG's pub/sub protocol. Subscribers can subscribe to one or multiple topics broadcast by a publisher.
326303

@@ -370,9 +347,7 @@ close(sub)
370347
371348
```
372349

373-
[&laquo; Back to ToC](#table-of-contents)
374-
375-
### Surveyor Respondent Protocol
350+
### 7. Surveyor Respondent Protocol
376351

377352
Useful for service discovery and similar applications. A surveyor broadcasts a survey to all respondents, who may reply within a timeout period. Late responses are discarded.
378353

@@ -415,9 +390,7 @@ close(res2)
415390

416391
The final value resolves to a timeout error (integer 5 classed as 'errorValue'). All error codes are classed as 'errorValue' for easy distinction from integer message values.
417392

418-
[&laquo; Back to ToC](#table-of-contents)
419-
420-
### ncurl: Async HTTP Client
393+
### 8. ncurl: Async HTTP Client
421394

422395
`ncurl()` is a minimalist http(s) client. `ncurl_aio()` performs async requests, returning immediately with an 'ncurlAio'.
423396

@@ -479,9 +452,7 @@ transact(sess)
479452
480453
```
481454

482-
[&laquo; Back to ToC](#table-of-contents)
483-
484-
### stream: Websocket Client
455+
### 9. stream: Websocket Client
485456

486457
`stream()` exposes NNG's low-level byte stream interface for communicating with raw sockets, including arbitrary non-NNG endpoints.
487458

@@ -519,9 +490,7 @@ close(s)
519490
520491
```
521492

522-
[&laquo; Back to ToC](#table-of-contents)
523-
524-
### Options, Serialization and Statistics
493+
### 10. Options, Serialization and Statistics
525494

526495
Use `opt()` and `'opt<-'()` to get and set options on Sockets, Contexts, Streams, Listeners, or Dialers. See function documentation for available options.
527496

@@ -569,5 +538,3 @@ stat(s, "pipes")
569538
570539
close(s)
571540
```
572-
573-
[&laquo; Back to ToC](#table-of-contents)

vignettes/nanonext.Rmd

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,7 @@ vignette: >
88

99

1010

11-
### Table of Contents
12-
13-
1. [Cross-language Exchange](#cross-language-exchange)
14-
2. [Async and Concurrency](#async-and-concurrency)
15-
3. [Synchronisation Primitives](#synchronisation-primitives)
16-
4. [TLS Secure Connections](#tls-secure-connections)
17-
5. [Request / Reply Protocol](#request-reply-protocol)
18-
6. [Publisher / Subscriber Protocol](#publisher-subscriber-protocol)
19-
7. [Surveyor / Respondent Protocol](#surveyor-respondent-protocol)
20-
8. [ncurl: (Async) HTTP Client](#ncurl-async-http-client)
21-
9. [stream: Websocket Client](#stream-websocket-client)
22-
10. [Options, Serialization and Statistics](#options-serialization-and-statistics)
23-
24-
### Cross-language Exchange
11+
### 1. Cross-language Exchange
2512

2613
`nanonext` provides a fast, reliable data interface between different programming languages where NNG has an implementation, including C, C++, Java, Python, Go, and Rust.
2714

@@ -78,9 +65,7 @@ n$recv(mode = "double")
7865
n$close()
7966
```
8067

81-
[&laquo; Back to ToC](#table-of-contents)
82-
83-
### Async and Concurrency
68+
### 2. Async and Concurrency
8469

8570
`nanonext` implements true async send and receive, leveraging NNG as a massively-scalable concurrency framework.
8671

@@ -166,9 +151,7 @@ close(s2)
166151

167152
```
168153

169-
[&laquo; Back to ToC](#table-of-contents)
170-
171-
### Synchronisation Primitives
154+
### 3. Synchronisation Primitives
172155

173156
`nanonext` implements cross-platform synchronisation primitives from the NNG library, enabling synchronisation between NNG events and the main R execution thread.
174157

@@ -244,9 +227,7 @@ When `flag = TRUE` is set for pipe notifications, `wait()` returns FALSE for pip
244227

245228
This mechanism enables waiting simultaneously on multiple events while distinguishing between them. `pipe_notify()` can signal up to two condition variables per event for additional flexibility in concurrent applications.
246229

247-
[&laquo; Back to ToC](#table-of-contents)
248-
249-
### TLS Secure Connections
230+
### 4. TLS Secure Connections
250231

251232
Secure connections use NNG and Mbed TLS libraries. Enable them by:
252233

@@ -266,7 +247,7 @@ The convenience function `write_cert()` generates a 4096-bit RSA key pair and se
266247
cert <- write_cert(cn = "127.0.0.1")
267248
str(cert)
268249
#> List of 2
269-
#> $ server: chr [1:2] "-----BEGIN CERTIFICATE-----\nMIIFOTCCAyGgAwIBAgIBATANBgkqhkiG9w0BAQsFADA0MRIwEAYDVQQDDAkxMjcu\nMC4wLjExETAPBgNV"| __truncated__ "-----BEGIN RSA PRIVATE KEY-----\nMIIJJwIBAAKCAgEAjt5sNS09hjIbA7SepY8Yv+TCkvNdFDXlwVGC0AQnxWnRr/9k\nHHZTSnt85rbG"| __truncated__
250+
#> $ server: chr [1:2] "-----BEGIN CERTIFICATE-----\nMIIFOTCCAyGgAwIBAgIBATANBgkqhkiG9w0BAQsFADA0MRIwEAYDVQQDDAkxMjcu\nMC4wLjExETAPBgNV"| __truncated__ "-----BEGIN RSA PRIVATE KEY-----\nMIIJKAIBAAKCAgEAwupvOgQzC3RQVt95gOTaOsDQ72tAbDzhHHLk9JfABqqWNpyl\nL7Fw3Foh7Nb9"| __truncated__
270251
#> $ client: chr [1:2] "-----BEGIN CERTIFICATE-----\nMIIFOTCCAyGgAwIBAgIBATANBgkqhkiG9w0BAQsFADA0MRIwEAYDVQQDDAkxMjcu\nMC4wLjExETAPBgNV"| __truncated__ ""
271252

272253
ser <- tls_config(server = cert$server)
@@ -287,9 +268,7 @@ close(s)
287268

288269
```
289270

290-
[&laquo; Back to ToC](#table-of-contents)
291-
292-
### Request Reply Protocol
271+
### 5. Request Reply Protocol
293272

294273
`nanonext` implements remote procedure calls (RPC) using NNG's req/rep protocol for distributed computing. Use this for computationally-expensive calculations or I/O-bound operations in separate server processes.
295274

@@ -327,7 +306,7 @@ When the result is needed, call the recvAio using `call_aio()` to retrieve the v
327306

328307
``` r
329308
call_aio(aio)$data |> str()
330-
#> num [1:100000000] -1.0996 -0.068 -1.2462 -0.5909 -0.0194 ...
309+
#> num [1:100000000] -1.532 -1.493 0.499 0.478 -0.118 ...
331310
```
332311

333312
Since `call_aio()` blocks, alternatively query `aio$data` directly, which returns 'unresolved' (logical NA) if incomplete.
@@ -336,9 +315,7 @@ For server-side operations (e.g., writing to disk), calling or querying the valu
336315

337316
The [`mirai`](https://doi.org/10.5281/zenodo.7912722) package (<https://mirai.r-lib.org/>) uses `nanonext` as the back-end to provide asynchronous execution of arbitrary R code using the RPC model.
338317

339-
[&laquo; Back to ToC](#table-of-contents)
340-
341-
### Publisher Subscriber Protocol
318+
### 6. Publisher Subscriber Protocol
342319

343320
`nanonext` implements NNG's pub/sub protocol. Subscribers can subscribe to one or multiple topics broadcast by a publisher.
344321

@@ -403,9 +380,7 @@ close(sub)
403380

404381
```
405382

406-
[&laquo; Back to ToC](#table-of-contents)
407-
408-
### Surveyor Respondent Protocol
383+
### 7. Surveyor Respondent Protocol
409384

410385
Useful for service discovery and similar applications. A surveyor broadcasts a survey to all respondents, who may reply within a timeout period. Late responses are discarded.
411386

@@ -454,9 +429,7 @@ close(res2)
454429

455430
The final value resolves to a timeout error (integer 5 classed as 'errorValue'). All error codes are classed as 'errorValue' for easy distinction from integer message values.
456431

457-
[&laquo; Back to ToC](#table-of-contents)
458-
459-
### ncurl: Async HTTP Client
432+
### 8. ncurl: Async HTTP Client
460433

461434
`ncurl()` is a minimalist http(s) client. `ncurl_aio()` performs async requests, returning immediately with an 'ncurlAio'.
462435

@@ -489,7 +462,7 @@ res
489462

490463
call_aio(res)$headers
491464
#> $date
492-
#> [1] "Tue, 02 Dec 2025 11:11:53 GMT"
465+
#> [1] "Tue, 02 Dec 2025 12:02:22 GMT"
493466

494467
res$data
495468
#> [1] "{\"args\":{},\"data\":{\"key\":\"value\"},\"files\":{},\"form\":{},\"headers\":{\"host\":\"postman-echo.com\",\"accept-encoding\":\"gzip, br\",\"x-forwarded-proto\":\"https\",\"content-type\":\"application/json\",\"authorization\":\"Bearer APIKEY\",\"content-length\":\"16\"},\"json\":{\"key\":\"value\"},\"url\":\"https://postman-echo.com/post\"}"
@@ -532,7 +505,7 @@ transact(sess)
532505
#>
533506
#> $headers
534507
#> $headers$Date
535-
#> [1] "Tue, 02 Dec 2025 11:11:53 GMT"
508+
#> [1] "Tue, 02 Dec 2025 12:02:22 GMT"
536509
#>
537510
#> $headers$`Content-Type`
538511
#> [1] "application/json; charset=utf-8"
@@ -549,9 +522,7 @@ transact(sess)
549522
#> [204] 2f 67 65 74 22 7d
550523
```
551524

552-
[&laquo; Back to ToC](#table-of-contents)
553-
554-
### stream: Websocket Client
525+
### 9. stream: Websocket Client
555526

556527
`stream()` exposes NNG's low-level byte stream interface for communicating with raw sockets, including arbitrary non-NNG endpoints.
557528

@@ -599,9 +570,7 @@ close(s)
599570

600571
```
601572

602-
[&laquo; Back to ToC](#table-of-contents)
603-
604-
### Options, Serialization and Statistics
573+
### 10. Options, Serialization and Statistics
605574

606575
Use `opt()` and `'opt<-'()` to get and set options on Sockets, Contexts, Streams, Listeners, or Dialers. See function documentation for available options.
607576

@@ -653,5 +622,3 @@ stat(s, "pipes")
653622

654623
close(s)
655624
```
656-
657-
[&laquo; Back to ToC](#table-of-contents)

0 commit comments

Comments
 (0)