Skip to main content

Module stomp

Module stomp 

Source
Expand description

STOMP 1.2 server implementation.

§Where the work is divided

Everything mechanical is done here in Rust and never asked of the model: frame boundaries, header escaping, the content-length/NUL body rule, the receipt handshake, heart-beat negotiation, and refusing a frame that violates the spec. The model decides content — admit this CONNECT or not, what a MESSAGE carries, whether to refuse.

That split is why receipt is handled generically: it is a property of the frame, not of what the frame means, and asking a model to remember it on every reply is asking it to get it wrong eventually. A client frame carrying receipt gets a RECEIPT back once the frame has been processed — after the model’s own output, as the spec requires.

§No per-connection state machine, deliberately

src/server/tcp/mod.rs carries an Idle/Processing/Accumulating machine because raw TCP has no frame boundaries: the reader task cannot know whether the bytes it just read complete a request, so a second read arriving mid-LLM-call has to be queued. STOMP does have frame boundaries, so this connection reads, parses out whole frames, and handles them one at a time in the same task. Bytes arriving during an LLM call sit in the socket buffer — TCP’s own backpressure — and are read on the next pass. There is no window in which two LLM calls could run for one connection, so there is no state to track.

§Failure behaviour

STOMP has an ERROR frame, so this server is never silent on failure. The peer is told a category (crate::utils::WireFailure) and the connection is closed, as the spec requires after an ERROR. The error itself goes to the log and the status stream only — never onto the wire.

stomp_connect is the one event where “the model said nothing” is not an acceptable answer: STOMP defines exactly two replies to CONNECT, and a client that receives neither blocks forever. So a connect event that produces no bytes is answered with an ERROR and closed, logged as decision=fail_closed_no_answer. For every other event silence is a real answer — a broker that accepts a SEND and says nothing is behaving normally.

Modules§

actions
STOMP 1.2 protocol actions.
frame
STOMP 1.2 frame codec.

Structs§

StompServer