Count every reconnect in reconnect_count (closes #68) #77

Merged
clawbot merged 1 commits from issue-68-reconnect-count into next 2026-10-14 15:59:15 +02:00
Collaborator

Fixes #68.

reconnect_count in /api/v1/stats stayed 0 however often the RIS Live stream reconnected. SetConnected counted a reconnect only when the stream was still marked connected, or when the count was already above zero. The streamer always marks the stream disconnected before it connects again, so neither held.

SetConnected now counts one reconnect for every connection after the first. It recognises the first connection by connectedSince, the time of the latest connection, which is zero until then, so no new field is needed.

The new test in internal/metrics connects, disconnects, connects, disconnects and connects, and expects a count of 2; before the fix it got 0.

Not visible in the diff: calling SetConnected(true) twice with no disconnect between still counts a reconnect, as it did before. The streamer never does this.

Judgement call: no Completed Steps entry in TODO.md, because the brief allows TODO.md changes only where this change makes it wrong.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/routewatch/issues/68. `reconnect_count` in `/api/v1/stats` stayed 0 however often the RIS Live stream reconnected. `SetConnected` counted a reconnect only when the stream was still marked connected, or when the count was already above zero. The streamer always marks the stream disconnected before it connects again, so neither held. `SetConnected` now counts one reconnect for every connection after the first. It recognises the first connection by `connectedSince`, the time of the latest connection, which is zero until then, so no new field is needed. The new test in `internal/metrics` connects, disconnects, connects, disconnects and connects, and expects a count of 2; before the fix it got 0. Not visible in the diff: calling `SetConnected(true)` twice with no disconnect between still counts a reconnect, as it did before. The streamer never does this. Judgement call: no Completed Steps entry in `TODO.md`, because the brief allows `TODO.md` changes only where this change makes it wrong. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 15:18:53 +02:00
clawbot self-assigned this 2026-10-14 15:18:53 +02:00
clawbot added 1 commit 2026-10-14 15:18:53 +02:00
SetConnected counted a reconnect only if the stream was still marked
connected or the count was already above zero. The streamer always marks
the stream disconnected before connecting again, so the count stayed 0.
It now counts one reconnect for every connection after the first, using
the time of the previous connection, which is zero until the first one.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit a43935308e into next 2026-10-14 15:59:15 +02:00
clawbot deleted branch issue-68-reconnect-count 2026-10-14 15:59:16 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#77