Expand description
BIDIR-6: Input<T>, the input half of a call.
BIDIR-6: the input half of a call. A method declares one parameter
Input<T> and reads what its caller streams into the live call.
→ {ns}.call {method, params} ← the subscription id, then credit {n: window}
→ {ns}.input {subscription, seq, items: [T…]} (seq counts frames from 0)
← ack {seq}, credit {n}, as the handler consumes
→ {ns}.end {subscription, seq} (seq: the number of frames sent)
← the method's items, done| when | then |
|---|---|
| a socket opens | the transport puts an InputTable on the FrameSink its calls’ extensions carry (FrameSink::with_inputs; a connection’s, so a frame of another socket reaches nothing) and hands it each input frame on its reader, inline, in arrival order, zero-copy: no task and no decode per frame |
{ns}.call dispatches | serve_call’s seam (CALL, a task-local) holds the unaccepted subscription; a method with no Input never looks at it, so its call is what it was |
a method with Input dispatches | open, after its params and its gate, before its body: the DuplexCall taken with the gate’s decision standing, the slot in the table before the subscription is accepted (so a frame sent on reading the id finds it), the subscription accepted, the Input handed to the method |
| anywhere with no seam or no table (stdio, HTTP, MCP, in process) | open refuses, naming the method: the call fails, it does not hang |
| a frame arrives | InputTable checks its seq (a resend below the next one is dropped; past it is out_of_sequence), that it holds an item (an empty frame is invalid_input), and what the call holds, then queues it; a frame past any of these is marked (Overrun) and is the last it takes |
| the pipe runs | one task, as any call: it polls DuplexCall::input (each frame admitted, the generation and the sign-in’s expiry selected beside it, so a call whose handler is not reading ends at a revoke all the same), the handler’s stream, and the ledger |
| the handler polls for the next item | everything before it counts as consumed: a handler that forwards before it polls reports what was forwarded. Half a window consumed, the pipe writes ack and credit |
| a WebSocket binary message (BIDIR-17) | [0x01][subscription: u64 BE][seq: u64 BE][payload]: one item, routed by InputTable::take_binary to the same slot and admission as a JSON frame, its payload a slice of the message, never copied; an Input<Bytes> gets it as is, an input of JSON items refuses it (invalid_input) |
Input<Bytes> over JSON | each item a base64 string, decoded when the handler reads it |
| the handler ends with the half open | input_closed {reason: "method_ended", ack}, then done; a later frame reaches nothing |
| a refusal | input_closed {reason, ack} and the typed error, the handler’s stream dropped; its Input never yields again (a refusal is not an end, so code after its read loop never runs) |
| the handler reads its input before it returns its stream | the pipe starts at the open, not at the route’s answer: credit and items flow, and a cancel or a lost socket ends the call, while the route is still resolving |
credit is what the handler consumes, not a number anyone chose
(BIDIR-6’s first decision): a client that obeys it meets no refusal.
Order is arrival: the socket’s reader takes frames in order, so seq is
for ack and end, not for reassembly.
Structs§
- Input
- The input half of a call: the items its caller streams in, as
T, in order, ending at the caller’send. - Input
Table - A connection’s open input halves, keyed by subscription, the slot of
BIDIR-5’s rule: (connection, subscription). The transport makes one a
connection, puts it on its calls’
FrameSink(with_inputs) and hands it frames.
Enums§
- Delivered
- What became of an input frame.
Constants§
- BINARY_
HEADER - A binary input frame’s header: the tag, the subscription, the seq.
- BINARY_
INPUT - BIDIR-17: the tag of a binary input frame,
[0x01][subscription: u64 BE][seq: u64 BE][payload](PERF-9’s msgpack keeps it free).