Skip to content

stream_server: decode requests in the per-stream read task - #212

Closed
mo4islona wants to merge 1 commit into
net-stream-server-workerfrom
stream-server-typed-requests
Closed

stream_server: decode requests in the per-stream read task#212
mo4islona wants to merge 1 commit into
net-stream-server-workerfrom
stream-server-typed-requests

Conversation

@mo4islona

Copy link
Copy Markdown
Contributor

Follow-up to #211, based on net-stream-server-worker so the diff shows only the delta.

Makes ServerBehaviour generic over the request message type and moves protobuf decoding from the worker actor into the per-stream read task.

Motivation:

  • Undecodable requests are dropped at the source, before taking a slot in the requests queue and the worker events queue, and the warn line now names the protocol.
  • Decoding runs concurrently (one task per stream), keeping protobuf parsing off the swarm event loop — with request_response it used to run in per-connection tasks.
  • The worker handlers lose the three repeated decode-and-log blocks and become one-liners again; the typed QueryBehaviour/LogsBehaviour/StatusBehaviour aliases are restored.

The cost is a single type parameter on ServerBehaviour/Request — request side only: responses stay raw bytes written via ResponseSender, so there is no codec pair as in the old request_response server.

Tests now encode a proper protobuf message (TestMsg), plus a new undecodable_request_rejected case covering the decode-failure path.

Verified locally: cargo test -p sqd-network-transport --features worker --lib (12 passed), cargo clippy --workspace --all-targets --all-features -- -D clippy::correctness, cargo +nightly fmt --check.

🤖 Generated with Claude Code

Make ServerBehaviour generic over the request message type and decode
requests in the per-stream read task instead of the swarm event loop:

- undecodable requests are dropped before taking a slot in the requests
  and events queues, and the log line names the protocol
- decoding runs concurrently, one task per stream, keeping protobuf
  parsing off the swarm event loop
- the worker handlers lose the repeated decode-and-log blocks and the
  typed behaviour aliases are restored

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mo4islona mo4islona closed this Jul 15, 2026
@mo4islona
mo4islona deleted the stream-server-typed-requests branch July 15, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant