Remove functions no longer needed by mirai (#287) Remove functions no longer needed by mirai Add tests Remove cancellation wire protocol Add tests
Remove functions no longer needed by mirai (#287)
Remove functions no longer needed by mirai
Add tests
Remove cancellation wire protocol
Fast, lightweight toolkit for messaging, concurrency, and the web in R. Built on NNG (Nanomsg Next Gen) and implemented almost entirely in C.
library(nanonext) # Open sockets s1 <- socket("req", listen = "ipc:///tmp/nanonext") s2 <- socket("rep", dial = "ipc:///tmp/nanonext") # Send s1 |> send("hello world") #> [1] 0 # Receive on the other s2 |> recv() #> [1] "hello world" close(s1) close(s2)
Non-blocking operations that resolve automatically:
s1 <- socket("rep", listen = "tcp://127.0.0.1:5556") s2 <- socket("req", dial = "tcp://127.0.0.1:5556") # Sender s2 |> send_aio("async request") # Async operations return immediately aio <- recv_aio(s1) aio #> < recvAio | $data > # Retrieve result when ready aio$data #> [1] "async request" close(s1) close(s2)
One server, one port – HTTP endpoints, WebSocket connections, and streaming all coexist. Mbed TLS built in for HTTPS/WSS.
# Generate self-signed certificates cert <- write_cert(cn = "127.0.0.1") # HTTPS server (port 0 = auto-assign a free port) server <- http_server( url = "https://127.0.0.1:0", handlers = list( handler("/", \(req) list(status = 200L, body = '{"status":"ok"}')) ), tls = tls_config(server = cert$server) ) server$start() # Async HTTPS client aio <- ncurl_aio(server$url, tls = tls_config(client = cert$client)) while (unresolved(aio)) later::run_now(1) aio$data #> [1] "{\"status\":\"ok\"}" server$close()
# CRAN install.packages("nanonext") # Development version install.packages("nanonext", repos = "https://r-lib.r-universe.dev")
Requires ‘libnng’ >= v1.11.0 and ‘libmbedtls’ >= 2.5.0, or ‘cmake’ to compile bundled libraries (libnng v1.11.1-pre, libmbedtls v3.6.5).
Recommended: Let the package compile bundled libraries for optimal performance:
Sys.setenv(NANONEXT_LIBS = 1) install.packages("nanonext")
System packages: libnng-dev / nng-devel, libmbedtls-dev / libmbedtls-devel. Set INCLUDE_DIR and LIB_DIR for custom locations.
INCLUDE_DIR
LIB_DIR
Requires Rtools. For R >= 4.2, cmake is included. Earlier versions need cmake installed separately and added to PATH.
Documentation | NNG | Mbed TLS | CRAN HPC Task View | CRAN Web Technologies
–
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
nanonext是一个用于R语言的高性能网络通信和并发编程库,提供异步消息传递、多线程和网络协议支持。
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
nanonext
Fast, lightweight toolkit for messaging, concurrency, and the web in R. Built on NNG (Nanomsg Next Gen) and implemented almost entirely in C.
Quick Start
Async I/O
Non-blocking operations that resolve automatically:
Web Toolkit
One server, one port – HTTP endpoints, WebSocket connections, and streaming all coexist. Mbed TLS built in for HTTPS/WSS.
Documentation
Installation
Building from Source
Linux / Mac / Solaris
Requires ‘libnng’ >= v1.11.0 and ‘libmbedtls’ >= 2.5.0, or ‘cmake’ to compile bundled libraries (libnng v1.11.1-pre, libmbedtls v3.6.5).
Recommended: Let the package compile bundled libraries for optimal performance:
System packages: libnng-dev / nng-devel, libmbedtls-dev / libmbedtls-devel. Set
INCLUDE_DIRandLIB_DIRfor custom locations.Windows
Requires Rtools. For R >= 4.2, cmake is included. Earlier versions need cmake installed separately and added to PATH.
Links
Documentation | NNG | Mbed TLS | CRAN HPC Task View | CRAN Web Technologies
Acknowledgements
–
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.