Async IO in streaming render — staggered resolve with io-sleep
Server (sx_server.ml): - eval_with_io: CEK evaluator with IO suspension handling (io-sleep, import) - io-sleep platform primitive: raises CekPerformRequest, resolved by eval_with_io - Streaming render uses eval_with_io for data + content evaluation - Data items with "delay" field sleep before resolving (async streaming) - Removed hardcoded streaming-demo-data — application logic belongs in .sx Application (streaming-demo.sx): - streaming-demo-data defined in SX: 3 items with 1s/3s/5s delays - Each item has delay, stream-id, and display data fields - Shell renders instantly, slots fill progressively as IO completes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -91,3 +91,48 @@
|
||||
(li (code ":content") " expression is re-evaluated with each yield's bindings")
|
||||
(li "Headers stream concurrently — independent of the data generator")
|
||||
(li "Future: SSE/WebSocket for re-resolving slots after initial page load")))))
|
||||
|
||||
(define
|
||||
streaming-demo-data
|
||||
(fn
|
||||
()
|
||||
(list
|
||||
(dict
|
||||
"stream-id"
|
||||
"stream-fast"
|
||||
"delay"
|
||||
1000
|
||||
"stream_label"
|
||||
"Fast source"
|
||||
"stream_color"
|
||||
"emerald"
|
||||
"stream_message"
|
||||
"Resolved in ~1s (async IO)"
|
||||
"stream_time"
|
||||
"~1s")
|
||||
(dict
|
||||
"stream-id"
|
||||
"stream-medium"
|
||||
"delay"
|
||||
3000
|
||||
"stream_label"
|
||||
"Medium source"
|
||||
"stream_color"
|
||||
"amber"
|
||||
"stream_message"
|
||||
"Resolved in ~3s (async IO)"
|
||||
"stream_time"
|
||||
"~3s")
|
||||
(dict
|
||||
"stream-id"
|
||||
"stream-slow"
|
||||
"delay"
|
||||
5000
|
||||
"stream_label"
|
||||
"Slow source"
|
||||
"stream_color"
|
||||
"violet"
|
||||
"stream_message"
|
||||
"Resolved in ~5s (async IO)"
|
||||
"stream_time"
|
||||
"~5s"))))
|
||||
|
||||
Reference in New Issue
Block a user