feat: per-call timeout — Client::call_with_timeout + Transport::recv_timeout - #7
Merged
Conversation
…_timeout
For a `@timeout_ms` function annotation: give up waiting for the response
after a deadline.
- Transport::recv_timeout(buf, Duration) -> Result<bool, _> -- `Ok(false)`
once the deadline passes. Default blocks (ignores the timeout) so a
clock-less transport still works; `std` impls override it:
- InMemory -> mpsc recv_timeout
- Tcp -> set_read_timeout around the length + body reads; a mid-frame
timeout desyncs the stream, so a timed-out Tcp call is fatal to the
connection (documented).
- Client::call_with_timeout(call_id, &P, Duration) -> maps a timed-out
recv to RuntimeError::Timeout (the variant existed, nothing produced it).
`call` / `call_with_timeout` now share one `request_response` helper.
tests/timeout_roundtrip.rs: an Echo stand-in -- one call with no server
times out (~50ms), one answered before a 5s deadline succeeds. All
feature configs green; no new clippy warnings.
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.
The runtime half of per-call settings (
@timeout_ms, §4.4): give up waiting for the response after a deadline.Transport::recv_timeout(buf, Duration) -> Result<bool, _>Ok(false)once the deadline passes. Default blocks (ignores the timeout) — a clock-lessno_stdtransport still works, it just can't honour a per-call deadline.InMemory::recv_timeoutmpsc::Receiver::recv_timeoutTcp::recv_timeoutset_read_timeoutaround the length + body reads. A mid-frame timeout desyncs the stream, so a timed-outTcpcall is fatal to the connection — drop theTcp(documented).Client::call_with_timeout(call_id, &P, Duration)recvtoRuntimeError::Timeout(the variant existed; nothing produced it until now).callandcall_with_timeoutshare one privaterequest_responsehelper.notify(one-way) takes no timeout — nothing to wait for.Test
tests/timeout_roundtrip.rs— anEchostand-in: onecall_with_timeoutwith no server times out at ~50ms →RuntimeError::Timeout; one answered before a 5s deadline succeeds. All feature configs green (--no-default-features,--features alloc, default); no new clippy warnings.Next
comline-codegen-rustreads@timeout_msfromFunction.parametersand emitscall_with_timeout(i, ¶ms, Duration::from_millis(N))for that function; no annotation →callas today.