Forward a response from the Data Plane to the waiting session. - If `response.partial` is true: sends the chunk but keeps the request in the map for subsequent chunks. - If `response.partial` is false: sends the final chunk and removes the request from the map. Returns `false` if the request was cancelled, timed out, or the session buffer is full (backpressure signal — the Data Plane should stop
(&self, response: Response)
| 67 | /// session buffer is full (backpressure signal — the Data Plane should |
| 68 | /// stop producing further chunks for this request). |
| 69 | pub fn complete(&self, response: Response) -> bool { |
| 70 | let is_final = !response.partial; |
| 71 | let mut pending = self.lock_pending(); |
| 72 | |
| 73 | if is_final { |
| 74 | if let Some(tx) = pending.remove(&response.request_id) { |
| 75 | tx.try_send(response).is_ok() |
| 76 | } else { |
| 77 | false |
| 78 | } |
| 79 | } else { |
| 80 | let request_id = response.request_id; |
| 81 | if let Some(tx) = pending.get(&request_id) { |
| 82 | match tx.try_send(response) { |
| 83 | Ok(()) => true, |
| 84 | Err(_) => { |
| 85 | // Full channel (session stalled) or closed (cancelled): |
| 86 | // evict the pending entry so the Data Plane stops |
| 87 | // producing further chunks for this request. |
| 88 | pending.remove(&request_id); |
| 89 | false |
| 90 | } |
| 91 | } |
| 92 | } else { |
| 93 | false |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// Remove a pending request (e.g., on session disconnect). |
| 99 | pub fn cancel(&self, id: &RequestId) { |