feat(groundcontrol): Implement in-memory cache for satellite group st… - #613
feat(groundcontrol): Implement in-memory cache for satellite group st…#613Dishank-Sen wants to merge 3 commits into
Conversation
…ates Signed-off-by: Dishank-Sen <dishanksen05@gmail.com>
|
Warning Review limit reached
Next review available in: 19 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe Ground Control server adds a synchronized in-memory cache for satellite group states. Lifecycle handlers refresh or invalidate entries, and ChangesSatellite group-state caching
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SetSatelliteConfig
participant GroupStatesCache
participant Database
SetSatelliteConfig->>GroupStatesCache: Read satellite group states
GroupStatesCache-->>SetSatelliteConfig: Return cached states on hit
SetSatelliteConfig->>Database: Retrieve groups on cache miss
Database-->>SetSatelliteConfig: Return group data or lookup error
SetSatelliteConfig->>GroupStatesCache: Store successful group states
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 38 |
| Duplication | 1 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/groundcontrol/server/group_handlers.go`:
- Around line 287-289: Update the group deletion flow around
setGroupStatesCache, q.DeleteGroup, and tx.Commit so recalculated states are
held in a local map during the transaction rather than written to the cache
immediately. Only populate the cache after tx.Commit succeeds, preserving the
existing state updates and leaving the cache unchanged when deletion or commit
fails.
In `@internal/groundcontrol/server/helpers.go`:
- Around line 411-415: Update getGroupStatesFromCache to return both the cached
[]string and a map-presence boolean, distinguishing cached nil/empty states from
missing satelliteID entries. Modify SetSatelliteConfig to use the boolean for
cache-hit decisions, and add coverage for a cached nil or empty group-state
entry to ensure database queries are not repeated.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b6f0a1ea-0d53-4aa2-b087-1b66e5d44e32
📒 Files selected for processing (6)
internal/groundcontrol/server/config_handlers.gointernal/groundcontrol/server/group_handlers.gointernal/groundcontrol/server/groupstates_cache_test.gointernal/groundcontrol/server/helpers.gointernal/groundcontrol/server/satellite_handlers.gointernal/groundcontrol/server/server.go
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Dishank-Sen
left a comment
There was a problem hiding this comment.
I have reviewed all the suggestion and made appropriate fixes.
Signed-off-by: Dishank-Sen <dishanksen05@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Signed-off-by: Dishank-Sen <dishanksen05@gmail.com>
Fixes: #583
Description
Implements an in-memory cache for satellite group states in Ground Control, addressing the TODO in
SetSatelliteConfig(config_handlers.go:489).Previously, every call to
SetSatelliteConfigqueried the database for all groups a satellite belongs to and fetched each group's details individually. The cache is keyed by satellite ID, protected by anRWMutex, and kept consistent across group modification operations.Additional context
Cache is invalidated/updated in
RegisterSatellite,AddSatelliteToGroup,RemoveSatelliteFromGroup,DeleteSatellite, andDeleteGroup. Unit tests added ingroupstates_cache_test.gocovering get/set roundtrips, invalidation, and per-satellite isolation.Summary by CodeRabbit