code wiki / (root) / nx_rpc.nx

nx_rpc.nx

buildroot/runtime/nx_rpc.nx

5784 B150 linesdepth 5pulls 6 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rpc.nx -- typed RPC over nx_net_chan_blob. Builds on nx_net_chan_blob's variable-length frames to give a request/response pattern: caller sends (method_id, request_blob), server dispatches to a registered handler indexed by method_id, returns (response_blob). Wire format per exchange: client -> server: 8 bytes: method_id (i64 big-endian via nx_net_chan_send) N bytes: request blob (length-prefix framed via nx_net_chan_send_blob) server -> client: N bytes: response blob (length-prefix framed) Sentinel method_id NX_RPC_SHUTDOWN signals server to exit cleanly. Handler table: a fixed-size array indexed by method_id. Each entry is a typed fn-ptr: func(*u8, n_req, *u8, max_resp) -> n_resp. Unregistered methods get a -1 response. Composes against: [[nx_net_chan_tcp_i64]] (method_id transport), [[nx_net_chan_blob_framing]] (request/response payload), [[fn_ptr_indirect_call]] (typed dispatch).

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_atom.nx nx_net_chan.nx nx_rpc.nx nx_rpc_test.nx

imports: nx_syscalls.nxnx_atom.nxnx_net_chan.nx

imported by: nx_rpc_test.nx

structs

38struct NxRpcHandlerEntry
45struct NxRpcServer

consts

35const NX_RPC_SHUTDOWN: i64 = -1
36const NX_RPC_MAX_METHODS: i64 = 64
43const NX_RPC_ENTRY_BYTES: i64 = 16

functions

52func _nx_rpc_handler_at(s: *NxRpcServer, idx: i64) -> *NxRpcHandlerEntry
59func nx_rpc_server_new(nc: *NxNetChan) -> *NxRpcServer
called by 1: main calls 1: sys_mmap
72func nx_rpc_register(s: *NxRpcServer, method_id: i64,
called by 1: main calls 1: _nx_rpc_handler_at
86func nx_rpc_server_run(s: *NxRpcServer, scratch_buf: *u8, scratch_cap: i64) -> i64
133func nx_rpc_call(nc: *NxNetChan, method_id: i64,
142func nx_rpc_shutdown_call(nc: *NxNetChan) -> i64
called by 1: rpc_client calls 1: nx_net_chan_send
147func nx_rpc_server_calls(s: *NxRpcServer) -> i64