Repository navigation
Say which requests are running right now - #83
Merged
Merged
Conversation
`GET /in-flight` returns the `request_started` event of every request that has not ended yet, verbatim, in start order. The event stream only tells a subscriber what happens after it subscribes. A request that started earlier and is still running has already had its start sent, so a listener counting "in progress" misses it until it ends. The desktop app's live overview is such a listener every time it opens: it said "idle" while a long request from before was still streaming. Treating this list as the starts it missed puts that listener where it would have been had it listened from the start. The bus keeps the table itself. `emit` records a start and strikes it off at any of the three endings, before sending, so by the time a subscriber sees an ending the snapshot no longer has it. This is not `Status::in_flight`, which counts connections from the moment they reach the data plane (queued and unauthenticated ones included) to answer "how many would a restart cut". The snapshot holds exactly the requests the event stream speaks of. Nothing in `track` can panic: `Ending` emits from `Drop`, possibly while unwinding, so a poisoned lock is read through rather than unwrapped. The table cannot only grow, because every start owes exactly one ending; the gateway's endings tests cover that, and one now checks that the snapshot empties with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
fylorn
added a commit
that referenced
this pull request
Sep 21, 2026
`GET /in-flight` returns the start events of the requests still running (#83), so a listener that subscribes mid-request can count what is in progress. Additive; CONTROL_API_VERSION unchanged. Co-authored-by: Claude Opus 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.
GET /in-flightreturns therequest_startedevent of every request that has not ended yet, verbatim, in start order.Why
The event stream only tells a subscriber what happens after it subscribes. A request that started earlier and is still running has already had its start sent, so a listener counting "in progress" misses it until it ends. The desktop app's live overview is such a listener every time it opens: it showed "Idle" while a long request from before was still streaming. Treating this list as the starts it missed puts that listener where it would have been had it listened from the start.
How
tw-observe:EventBuskeeps the table itself.emitrecords a start and strikes it off at any of the three endings, before sending, so by the time a subscriber sees an ending the snapshot no longer has it.in_flight()returns the stored start events.tw-control:GET /in-flightreturnsbus.in_flight().This is not
Status::in_flight. That counts connections from the moment they reach the data plane, queued and unauthenticated ones included, to answer "how many would a restart cut". The snapshot holds exactly the requests the event stream speaks of.Nothing in
trackcan panic, becauseEndingemits fromDrop, possibly while unwinding; a poisoned lock is read through. The table cannot only grow, because every start owes exactly one ending.Tests
bus.rs: starts that have not ended are listed, all three endings strike them off, headers don't, and the snapshot is kept with no subscriber and in start order.tests/in_flight.rs: the endpoint's JSON has the same shape as the stream's start events; nothing running is an empty list.tests/endings.rs: through a real gateway, a request is in the snapshot while its stream is open and gone once its ending is reported.cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo test --workspacepass locally, the last withHTTP_PROXYunset for this machine's local proxy.Additive; the next tag is a patch.
🤖 Generated with Claude Code