preludes / rpc.lisp
rpc
Effect RPC. Unary RPC contracts and named groups that emit native Effect 4 schemas and registrations.
Handlers and transports remain native Effect code. No RPC execution kernel is generated.
From the source
Purpose: Unary Effect 4 RPC contracts, grouped for native handler registration. Requires: compiler.lisp. Consumers provide handlers and transport layers.
Forms 2
Keywords this prelude adds. Each is a form descriptor: its slots, their types, and the IR it produces.
(rpc name {:keys [payload success error]})rpc.lisp:9
Declares a unary RPC with request and success schemas and an optional error schema.
| Slot | Type |
|---|---|
| name | String |
| payload | Type |
| success | Type |
| error | (Option Type) |
Produces RpcIR · has a TypeScript :emit hook
Example
(rpc-group Greetings
(rpc "Greet" :payload {:name String} :success String))(rpc-group name operation ...)rpc.lisp:23
Groups RPC contracts with unique wire names. Native Effect supplies handlers and transport.
| Slot | Type |
|---|---|
| name | (Declares RpcGroupDecl) |
| operation | (List rpc) |
Produces RpcGroupIR · has a TypeScript :emit hook
Example
(type Greeting {:message String})
(error Unavailable {:reason String})
(rpc-group Greetings
(rpc "Greet" :payload {:name String} :success Greeting :error Unavailable))Types 2
Payload contracts and IR shapes, shown as authored.
RpcIRrpc.lisp:5
(type RpcIR
{:kind "Rpc" :name String :payload Type :success Type :error (Option Type)})RpcGroupIRrpc.lisp:7
(type RpcGroupIR {:kind "RpcGroup" :name Symbol :operations (List RpcIR)})