pub struct PendingRequests { /* private fields */ }Expand description
Tracks pending server-to-client requests.
When the server sends a request to the client, it registers a response sender here. When a response arrives, the dispatcher routes it to the correct sender.
Implementations§
Source§impl PendingRequests
impl PendingRequests
Sourcepub fn with_max_in_flight(max_in_flight: usize) -> McpResult<Self>
pub fn with_max_in_flight(max_in_flight: usize) -> McpResult<Self>
Creates a tracker with a caller-selected finite in-flight limit.
§Errors
Returns InvalidParams when max_in_flight is zero or exceeds
HARD_MAX_IN_FLIGHT_REQUESTS.
Sourcepub const fn max_in_flight(&self) -> usize
pub const fn max_in_flight(&self) -> usize
Returns the configured maximum number of in-flight requests.
Sourcepub fn in_flight_len(&self) -> usize
pub fn in_flight_len(&self) -> usize
Returns the current number of in-flight requests.
Sourcepub fn route_response(&self, response: &JsonRpcResponse) -> bool
pub fn route_response(&self, response: &JsonRpcResponse) -> bool
Routes a response to the appropriate pending request.
Returns true only when the response was delivered to a live pending
request, preserving the established public boolean contract.
Sourcepub fn remove(&self, id: &RequestId)
pub fn remove(&self, id: &RequestId)
Removes a pending request (e.g., on timeout or cancellation).
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Permanently closes the tracker and cancels every pending request.
Closing is irreversible: later registration attempts fail with the same fixed connection-closed error. This prevents a request racing with connection teardown from installing an orphaned waiter after the drain.