This repository was archived by the owner on Sep 30, 2024. It is now read-only.
chore(worker): move refreshAnalyticsCache to worker#64041
Merged
stefanhengl merged 4 commits intomainfrom Jul 25, 2024
Merged
Conversation
eseliger
reviewed
Jul 24, 2024
eseliger
approved these changes
Jul 24, 2024
Comment on lines
+15
to
+20
| func store() redispool.KeyValue { | ||
| if MockStore != nil { | ||
| return MockStore | ||
| } | ||
| return redispool.Store | ||
| } |
Member
There was a problem hiding this comment.
Doesn't have to happen in this PR, but generally I would be a fan if we don't use the global redispool.Store and global mocks around them so much, and instead pass down a redispool.KeyValue explicitly from the worker Routines init functions. That makes testing easier, and makes clearer which service actually has a dependency on redis.
Since this packages lives in /internal/adminanalytics it's not very clear that only frontend and worker need redis, but for example searcher would not for this purpose.
Member
Author
There was a problem hiding this comment.
I agree. I will follow up in a separate PR.
stefanhengl
added a commit
that referenced
this pull request
Jul 26, 2024
Relates to #64041 This refactors the `adminanalytics` package to set the cache explicitly instead of implicitly relying on the global `redispool.Store`. The global store obfuscated the dependency and also made testing a bit awkward. Test plan: - new unit test - I ran a local instance and checked for panics in the logs from the worker job that updates the cache on startup. - Checked that the following GQL query returned results ```GQL query { site { analytics { search(dateRange: LAST_MONTH, grouping: WEEKLY) { searches { nodes { date count } summary { totalCount totalUniqueUsers totalRegisteredUsers } } } } } } ``` - I deleted the cache and ran the GQL query again and verified that cache had the following new entries ``` 1) "adminanalytics:Search:Searches:LAST_MONTH:WEEKLY:nodes" 2) "adminanalytics:Search:Searches:LAST_MONTH:WEEKLY:summary" ```
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This moves the
refreshAnalyticsCachejob fromfrontendtoworkerNotes:
the
adminanalyticspackage uses a global cache which made testing awkward. That's why I introduced thestore()abstraction to swap the store at test time.Test plan