Skip to content

Say which requests are running right now - #83

Merged
fylorn merged 1 commit into
mainfrom
feat/in-flight-snapshot
Sep 21, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/in-flight-snapshot

Conversation

@fylorn

@fylorn fylorn commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

GET /in-flight returns the request_started event 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: EventBus 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. in_flight() returns the stored start events.
  • tw-control: GET /in-flight returns bus.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 track can panic, because Ending emits from Drop, 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 --workspace pass locally, the last with HTTP_PROXY unset for this machine's local proxy.

Additive; the next tag is a patch.

🤖 Generated with Claude Code

`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>
@fylorn
fylorn merged commit 08718df into main Sep 21, 2026
1 check passed
@fylorn
fylorn deleted the feat/in-flight-snapshot branch September 21, 2026 13:52
@fylorn fylorn mentioned this pull request Sep 21, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant