March Docs

NetKernel

NetKernel: the socket-level transport for distributed OTP (P1).

Bridges the pure protocol layer (NetFrame / NodeIdentity / ClusterAuth / Handshake, all over List(Int) bytes) to real TCP sockets (Socket, over String). It frames messages, reads complete frames off a byte stream (partial-read safe), and runs the authenticated handshake that gates a peer into the cluster.

The pure bridge (to_wire / str_to_bytes / bytes_to_str) is unit-tested; the socket handshake is runtime-exercised (sockets/scheduler are not run by the eval-based stdlib test harness, matching ChannelServer's convention).

P5 frame types (tag byte prepended before the msgpack payload): 0x05 REGISTRY_SYNC_REQ [tag=5, root_hash:Str] 0x06 REGISTRY_SYNC_RESP [tag=6, root_hash:Str, leaves:[[name,nid,pid,clock_json,present],...]] 0x07 MONITOR_REQ [tag=7, watcher_node:Str, watcher_pid:Int, target_pid:Int] 0x08 MONITOR_FIRE [tag=8, target_pid:Int, reason_tag:Int, reason_msg:Str] reason_tag: 0=Normal, 1=Killed, 2=Crash, 3=NodeDown

Functions

fnbytes_to_strbytes_to_str(b : List(Int)) : String do Bytes.to_string(Bytes.from_list(b)) end#
fndecode_monitor_firedecode_monitor_fire(bytes : List(Int)) : Result((Int, Int, String), String)#
fndecode_monitor_reqdecode_monitor_req(bytes : List(Int)) : Result((String, Int, Int), String)#
fndecode_registry_sync_reqdecode_registry_sync_req(bytes : List(Int)) : Result(String, String)#
fndecode_registry_sync_respdecode_registry_sync_resp(bytes : List(Int)) : Result((String, List((String, GlobalRegistry.Entry))), String)#
fnencode_monitor_fireencode_monitor_fire(target_pid : Int, reason_tag : Int, reason_msg : String) : List(Int)#
fnencode_monitor_reqencode_monitor_req(watcher_node : String, watcher_pid : Int, target_pid : Int) : List(Int)#
fnencode_registry_sync_reqencode_registry_sync_req(root_hash : String) : List(Int)#
fnencode_registry_sync_respencode_registry_sync_resp(root_hash : String,#
fnframe_tagframe_tag(bytes : List(Int)) : Option(Int)#
fnfresh_noncefresh_nonce() : String do Crypto.random_hex(16) end#
fnhandshakehandshake(fd : Int, my_id : NodeIdentity.Identity, secret : String,#
fnrecv_framerecv_frame(fd : Int, buf : List(Int)) : Result((List(Int), List(Int)), String)#
fnsend_framesend_frame(fd : Int, payload : List(Int)) : Result((), String)#
fnstr_to_bytesstr_to_bytes(s : String) : List(Int) do Bytes.to_list(Bytes.from_string(s)) end#
fnto_wireto_wire(payload : List(Int)) : String#