Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughRemoved the clock abstraction: deleted Handler.Clock and Services.CachedClock, removed clock imports, replaced h.Clock.Now()/cached clock uses with time.Now(), and updated tests and test utilities to stop injecting CachedClock. Changes
Sequence Diagram(s)(omitted — changes are refactors of time source and do not introduce new control-flow interactions) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
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 |
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
go/apps/api/routes/register.go(0 hunks)go/apps/api/routes/services.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/200_test.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/400_test.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/401_test.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/403_test.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/410_test.go(0 hunks)go/apps/api/routes/v2_ratelimit_multi_limit/handler.go(3 hunks)go/apps/api/run.go(0 hunks)go/pkg/testutil/http.go(1 hunks)go/pkg/uid/uid.go(1 hunks)
💤 Files with no reviewable changes (8)
- go/apps/api/routes/v2_ratelimit_multi_limit/200_test.go
- go/apps/api/routes/v2_ratelimit_multi_limit/410_test.go
- go/apps/api/routes/services.go
- go/apps/api/routes/register.go
- go/apps/api/run.go
- go/apps/api/routes/v2_ratelimit_multi_limit/401_test.go
- go/apps/api/routes/v2_ratelimit_multi_limit/403_test.go
- go/apps/api/routes/v2_ratelimit_multi_limit/400_test.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-15T14:59:30.212Z
Learnt from: chronark
Repo: unkeyed/unkey PR: 3560
File: go/deploy/metald/internal/database/repository.go:0-0
Timestamp: 2025-07-15T14:59:30.212Z
Learning: go/deploy/metald cannot currently import helpers from go/pkg/db because it is not yet part of the main Go module; avoid suggesting such imports until the modules are unified.
Applied to files:
go/apps/api/routes/v2_ratelimit_multi_limit/handler.go
🧬 Code graph analysis (1)
go/pkg/testutil/http.go (2)
go/pkg/clock/interface.go (1)
Clock(12-18)go/pkg/clock/test_clock.go (1)
TestClock(11-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Test Go API Local / Test
- GitHub Check: Test API / API Test Local
- GitHub Check: Build / Build
🔇 Additional comments (2)
go/pkg/testutil/http.go (1)
39-39: LGTM! TestClock appropriately retained for test control.The removal of
CachedClockwhile keeping theTestClockfield is correct. TheTestClockprovides controllable time for test fixtures (like line 334 setting up analytics timestamps), which is essential for deterministic tests. This aligns perfectly with the PR objective to remove the production cached clock that was causing CPU regression.Also applies to: 334-334
go/apps/api/routes/v2_ratelimit_multi_limit/handler.go (1)
201-211: LGTM! Clean transition to direct time.Now() with test mode support.The replacement of
h.Clock.Now()withtime.Now()at lines 201, 253, and 338 is correct and consistent. The test mode handling (lines 202-211) via theX-Test-Timeheader provides an alternative mechanism for controlling time in tests, maintaining test determinism without the overhead of the cached clock. This change directly addresses the CPU regression mentioned in the PR objectives.Also applies to: 253-253, 338-338
Graphite Automations"Post a GIF when PR approved" took an action on this PR • (11/14/25)1 gif was posted to this PR based on Andreas Thomas's automation. |

What does this PR do?
Our recent CPU profiles after our deployment yday shows an increased cpu usage to before.
This is mostly due to the 2 timers that run each millisecond to update the cached clock.
So using it might be faster at somepoint but not today.
Type of change
How should this be tested?
Tests should still work
Checklist
Required
pnpm buildpnpm fmtmake fmton/godirectoryconsole.logsgit pull origin mainAppreciated