fix(monitor): fetch radar image only on change, not every poll#127
Merged
Conversation
processStation was calling the image source on every CheckInterval
tick, regardless of whether the radar data had changed. The fetched
image was then discarded for all polls except the ones that triggered
a notification (first run, or VCP change). At the 5-min default that
absorbed ~12 wasted renderer calls per station per hour.
Move fetchRadarImage into the two paths that actually need an image:
- First run — startup notification always carries an image so the
user has visual context the moment the monitor comes online.
- VCP change — the only mid-run change type that ships an
attachment (per attachmentForChange).
Other change types (power source, mode shifts without VCP) reach the
user as text-only and don't justify a render. No-change polls now
skip the image source entirely.
Two new tests pin the regression:
- TestNoChangePollSkipsImageSource — repeated identical-data polls
fetch exactly once (the startup poll), never on subsequent ticks.
- TestNonVCPChangePollSkipsImageSource — power-source flips don't
trigger a fetch even though they fire a notification.
Existing TestVCPChangeDeliversAttachment continues to pass: the
freshly-rendered image still lands on the change notification because
fetchRadarImage runs just-in-time in the VCP-change branch instead of
opportunistically before comparison.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 2.13.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
5 tasks
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.
Summary
processStationwas calling the image source on everyCheckIntervaltick, regardless of whether the radar data had changed. The fetched image was then discarded for all polls except the ones that triggered a notification (first run, or VCP change). At the 5 min default that absorbed ~12 wasted renderer calls per station per hour.Move
fetchRadarImageinto the two paths that actually need an image:attachmentForChange).Other change types (power source flips, mode shifts without VCP) reach the user as text-only and don't justify a render. No-change polls now skip the image source entirely.
Why
The renderer is the heaviest hop in the pipeline (S3 fetch + Py-ART decode + Cartopy plot per request). Burning a full render every 5 min per station to discard the result was pure waste — and at scale it scales linearly with both station count and poll frequency.
Tests
Two new tests pin the regression:
TestNoChangePollSkipsImageSource— repeated identical-data polls fetch exactly once (the startup poll), never on subsequent ticks.TestNonVCPChangePollSkipsImageSource— power-source flips don't trigger a fetch even though they fire a notification.TestVCPChangeDeliversAttachmentcontinues to pass: the freshly-rendered image still lands on the change notification becausefetchRadarImageruns just-in-time in the VCP-change branch instead of opportunistically before comparison.Test plan
go test ./internal/monitor/...— passes (full suite)go test ./...— all packages green🤖 Generated with Claude Code