src/sys.bend relies on unsafe/foreign
raw source on the hub · import bend-kube-runtime@0.9.0.0/src/sys.bend as Sys
1 import
import Base
Definitions
def Sys.listen.js source · line 26 · raw
String
What the JS lane's Sys.listen.dual answers (effs/sys.js).
def Sys.listen.v4 source · line 29 · raw
@+port:U32 -> @c:U32 -> @+m:String -> @lane:Bool -> IO(Result<&1, &1, Pair(U32, String), Listener>)
def Sys.listen.got source · line 36 · raw
@r:Result<&1, &1, Pair(U32, String), Listener> -> @+port:U32 -> IO(Result<&1, &1, Pair(U32, String), Listener>)
def Sys.listen source · line 48 · raw
@+port:U32 -> IO(Result<&1, &1, Pair(U32, String), Listener>)
A listener on every address of port: IPv6 and IPv4 (dual-stack), so probes and webhooks answer on IPv6-only and dual-stack clusters; IPv4 only on a host without IPv6, and on the JS lane.
Effects (foreign code)
effect Sys.wall source · line 12 · raw
IO(Pair(U32, Pair(U32, U32)))
The wall clock: (days since 1970-01-01, (second of the day, microseconds)). time.bend's Wall.of makes it a Wall.
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.signal source · line 17 · raw
IO(U32)
Waits for SIGTERM or SIGINT; answers the signal's number.
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.listen.dual source · line 21 · raw
@port:U32 -> IO(Result<&1, &1, Pair(U32, String), Listener>)
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.memo_get source · line 55 · raw
@key:String -> @now:U32 -> IO(String)
A process-wide table of short strings that expire (wall-clock seconds, as Wall.secs counts them): what must outlive one request, such as an exec credential plugin's token. A missing or expired key answers "".
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.memo_put source · line 59 · raw
@key:String -> @value:String -> @until:U32 -> IO(Unit)
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.unix_listen source · line 69 · raw
@path:String -> @mode:U32 -> IO(Result<&1, &1, Pair(U32, String), Listener>)
A listener on the Unix socket at path (at most 103 bytes on macOS, 107 on Linux), which TCP.accept serves. A socket file left by a server that is gone is replaced; a live server's fails with EADDRINUSE (48 on macOS, 98 on Linux), and any other file there with EEXIST, never removed. mode, unless 0, is the socket file's permission bits (0o600 = 384: the owner only). The native lane only: the JS lane answers Fail.
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.unix_connect source · line 75 · raw
@path:String -> IO(Result<&1, &1, Pair(U32, String), Socket>)
A socket connected to the Unix socket at path, for TCP.send and TCP.recv. The native lane only.
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.dup source · line 82 · raw
@sock:Socket -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Socket>))
A second handle on sock's connection (dup(2)): one computation reads while another writes, each owning a handle. The connection lasts until both are closed; Sys.shutdown ends it for both.
foreign: src/effs/sys.c, src/effs/sys.js
effect Sys.shutdown source · line 88 · raw
@sock:Socket -> IO(Socket)
shutdown(2) both ways: a recv on any handle of the connection ends. The handle stays open until closed.
foreign: src/effs/sys.c, src/effs/sys.js