| Title: | 'R'/'Go' 'IPC' using 'Nanomsg' Next Gen |
|---|---|
| Description: | The tools provide an interface for inter-process communication ('IPC') between 'R' and 'Go' using the 'Nanomsg' library. It vendors on the 'Go' side the 'mangos' library <https://github.com/nanomsg/mangos> and 'arrow-go' <https://github.com/apache/arrow-go> and uses 'nanonext' and 'nanoarrow' on the 'R' side. |
| Authors: | Sounkou Mahamane Toure [aut, cre], Mangos (nanomsg) contributors [cph], The Go Authors [cph], Apache Arrow Project [cph] |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.15.9000 |
| Built: | 2026-05-14 08:45:08 UTC |
| Source: | https://github.com/sounkou-bioinfo/mangoro |
Create a unique IPC path for mangoro
create_ipc_path(prefix = "mangoro-echo")create_ipc_path(prefix = "mangoro-echo")
prefix |
Prefix for the temp file (default: "mangoro-echo") |
IPC URL string suitable for nanonext and mangoro Go binaries
Find the path to the mangoro vendor directory
find_mangoro_vendor()find_mangoro_vendor()
Path to the vendor directory (inst/go/vendor)
Get the version of vendored Arrow Go using Go tooling (no jsonlite)
get_arrow_go_version()get_arrow_go_version()
The version string of github.com/apache/arrow/go/v18 in the vendor go.mod
Get the version of vendored mangos using Go tooling (no jsonlite)
get_mangos_version()get_mangos_version()
The version string of go.nanomsg.org/mangos/v3 in the vendor go.mod
Builds a list of candidate go paths from package options, environment
variables, PATH entries, and platform-specific defaults. This function does
not validate candidates.
go_binary_candidates()go_binary_candidates()
Character vector of candidate Go binary paths
Compiles a Go source file using the vendored dependencies from the mangoro package.
To comply with CRAN policy, this function temporarily redirects several environment variables to prevent Go from writing to user directories:
HOME is set to a temporary directory because Go's telemetry system
(introduced in Go 1.23+) writes data to ~/.config/go/telemetry
using os.UserConfigDir(), which cannot be disabled via environment
variables alone.
GOCACHE is set to a temporary directory to prevent build cache
writes to ~/.cache/go-build.
GOENV is set to a temporary file to prevent config writes to
~/.config/go/env.
All environment variables are restored and temporary directories cleaned up after the build completes.
mangoro_go_build(src, out, gomaxprocs = 1, gocache = NULL, ...)mangoro_go_build(src, out, gomaxprocs = 1, gocache = NULL, ...)
src |
Path to the Go source file |
out |
Path to the output binary |
gomaxprocs |
Number of threads for Go build (sets GOMAXPROCS env variable) |
gocache |
Path to Go build cache directory. If NULL (default), uses a temporary directory to comply with CRAN policy. Set to NA to use the default Go cache location. |
... |
Additional arguments to pass to Go build |
Path to the compiled binary
https://go.dev/doc/telemetry for Go telemetry documentation
Start an HTTP file server via RPC
mangoro_http_start( sock, addr, dir = ".", prefix = "/", cors = FALSE, coop = FALSE, tls = FALSE, cert = NULL, key = NULL, silent = FALSE )mangoro_http_start( sock, addr, dir = ".", prefix = "/", cors = FALSE, coop = FALSE, tls = FALSE, cert = NULL, key = NULL, silent = FALSE )
sock |
A nanonext socket connected to the HTTP server controller |
addr |
Address to bind server to (e.g., "127.0.0.1:8080") |
dir |
Directory to serve (default: current directory) |
prefix |
URL prefix for the server (default: "/") |
cors |
Enable CORS headers (default: FALSE) |
coop |
Enable Cross-Origin-Opener-Policy (default: FALSE) |
tls |
Enable TLS (default: FALSE) |
cert |
Path to TLS certificate file (required if tls = TRUE) |
key |
Path to TLS key file (required if tls = TRUE) |
silent |
Suppress server logs (default: FALSE) |
List with status and message
Get HTTP server status via RPC
mangoro_http_status(sock)mangoro_http_status(sock)
sock |
A nanonext socket connected to the HTTP server controller |
List with status and message
Stop the HTTP file server via RPC
mangoro_http_stop(sock)mangoro_http_stop(sock)
sock |
A nanonext socket connected to the HTTP server controller |
List with status and message
Locates a usable go binary for runtime IPC helpers. Resolution order:
options(mangoro.go_path)
Sys.getenv("MANGORO_GO")
PATH entries and platform defaults via go_binary_candidates()
Candidates are validated by running go version and checking the minimum
required Go version from the vendored go.mod. Errors reference the
detected OS/arch using user-friendly labels (e.g., macOS arm64).
mangoro_min_go_version()mangoro_min_go_version()
Path to the Go binary
Pack a 32-bit integer to raw bytes (big-endian)
mangoro_pack_int32(x)mangoro_pack_int32(x)
x |
An integer value |
A raw vector of length 4
Call a remote function via RPC
mangoro_rpc_call(sock, func_name, data)mangoro_rpc_call(sock, func_name, data)
sock |
A nanonext socket connected to the RPC server |
func_name |
Name of the function to call |
data |
Data frame or Arrow stream to send as arguments |
The result from nanoarrow::read_nanoarrow (typically a nanoarrow_array_stream)
Create an RPC function call message
mangoro_rpc_call_message(func_name, data)mangoro_rpc_call_message(func_name, data)
func_name |
Name of the function to call |
data |
Data frame or Arrow stream to send as arguments |
A raw vector containing the RPC call message
Get the manifest of registered functions from an RPC server
mangoro_rpc_get_manifest(sock)mangoro_rpc_get_manifest(sock)
sock |
A nanonext socket connected to the RPC server |
A list of function signatures
Create an RPC manifest request message
mangoro_rpc_manifest_request()mangoro_rpc_manifest_request()
A raw vector containing the manifest request
Parse an RPC response message
mangoro_rpc_parse_response(response)mangoro_rpc_parse_response(response)
response |
Raw vector containing the RPC response |
A list with components: type, func_name, error_msg, data
Receive a message with retries
mangoro_rpc_recv(sock, max_attempts = 20)mangoro_rpc_recv(sock, max_attempts = 20)
sock |
A nanonext socket |
max_attempts |
Maximum number of retry attempts (default 20) |
The received message as a raw vector
Send a message with retries
mangoro_rpc_send(sock, msg, max_attempts = 20)mangoro_rpc_send(sock, msg, max_attempts = 20)
sock |
A nanonext socket |
msg |
Message to send (raw vector) |
max_attempts |
Maximum number of retry attempts (default 20) |
The result from nanonext::send
Unpack a 32-bit integer from raw bytes (big-endian)
mangoro_unpack_int32(bytes)mangoro_unpack_int32(bytes)
bytes |
A raw vector of length 4 |
An integer value