stream_server: decode requests in the per-stream read task - #212
Closed
mo4islona wants to merge 1 commit into
Closed
stream_server: decode requests in the per-stream read task#212mo4islona wants to merge 1 commit into
mo4islona wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #211, based on
net-stream-server-workerso the diff shows only the delta.Makes
ServerBehaviourgeneric over the request message type and moves protobuf decoding from the worker actor into the per-stream read task.Motivation:
request_responseit used to run in per-connection tasks.QueryBehaviour/LogsBehaviour/StatusBehaviouraliases are restored.The cost is a single type parameter on
ServerBehaviour/Request— request side only: responses stay raw bytes written viaResponseSender, so there is no codec pair as in the oldrequest_responseserver.Tests now encode a proper protobuf message (
TestMsg), plus a newundecodable_request_rejectedcase 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