mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
An op is an async fn. It may take &zip::Cx (request headers; the answer's status, headers and trailers) and a zip::Body read as it arrives, and may answer zip::Sse or zip::Body, each chunk written as the op yields it. A client that leaves drops the op's stream. The blocking std::net door is gone: HTTP/1.1 keep-alive and h2c on one port (hyper_util auto), graceful shutdown bounded by a grace. The ZAP door runs on tokio and streams with zap-proto/http's head, data and end frames. Wire names are serde's: the derive reads rename, rename_all, skip and with, and the hand-rolled JSON is deleted. The info manifest comes out byte for byte as before. No zapgen emits Rust, so the crate never built; the frame codec is written in zap.rs and pinned to frames Go wrote. The length prefix is big-endian, as zap-proto/http's transport writes it. examples/stream is a JSON op, an SSE op with a trailer and a byte relay, tested over raw HTTP/1.1, h2c and ZAP sockets. Claude-Session: https://claude.ai/code/session_01SCPMGSQsLNF2YtHFL4bwyp
2 lines
1.3 KiB
JSON
2 lines
1.3 KiB
JSON
{"manifest":1,"app":"stream","title":"Streaming","version":"1.0.0","description":"One JSON op, one event stream and one byte relay.","ops":[{"method":"POST","path":"/v1/echo","description":"Echo answers the text it was sent.","pkg":"stream","in":"Text","out":"Text","example":{"text": "hi"},"response":{"text": "hi"}},{"method":"POST","path":"/v1/count","description":"Count streams n ticks as server-sent events, then [DONE], and reports how\nmany it sent in the x-sent trailer.","pkg":"stream","in":"Count","example":{"n": 3, "everyMs": 100},"stream":"sse"},{"method":"POST","path":"/v1/relay","description":"Relay answers the body it was sent, each chunk as it arrives, under the\ncontent type it was sent with.","pkg":"stream","stream":"bytes","raw":true}],"types":[{"id":"Count","name":"Count","kind":"struct","spell":"Count","doc":"Count asks for a stream of ticks.","fields":[{"name":"n","json":"n","required":true,"doc":"N is how many ticks to send.","type":{"prim":"u32"},"spell":"u32"},{"name":"every_ms","json":"everyMs","doc":"EveryMs is the pause before each tick, in milliseconds.","type":{"prim":"u64"},"spell":"u64"}]},{"id":"Text","name":"Text","kind":"struct","spell":"Text","doc":"Text is a line of text.","fields":[{"name":"text","json":"text","required":true,"doc":"Text is the line.","type":{"prim":"string"},"spell":"String"}]}]}
|