Refactor ScriptHelper class to be thread-safe#10304
Merged
mitchellhenke merged 3 commits intomainfrom Mar 25, 2024
Merged
Conversation
zachmargolis
approved these changes
Mar 25, 2024
app/helpers/script_helper.rb
Outdated
Contributor
There was a problem hiding this comment.
request_store is only a transitive dependency of lograge, if we're using it directly like this, WDYT of making it an explicit dependency?
Contributor
Author
There was a problem hiding this comment.
Oops, yes, meant to do that
Contributor
Author
There was a problem hiding this comment.
Added in 14f47f599a
app/helpers/script_helper.rb
Outdated
Comment on lines
11
to
10
Contributor
There was a problem hiding this comment.
Do you think this would be a good case to use the .fetch API from the gem?
Suggested change
| if scripts | |
| RequestStore.store[:scripts].merge!(names.index_with(attributes)) | |
| else | |
| RequestStore.store[:scripts] = names.index_with(attributes) | |
| end | |
| RequestStore.fetch(:scripts) do | |
| names.index_with(attributes) | |
| end.merge!(names.index_with(attributes)) |
Contributor
Author
There was a problem hiding this comment.
I was trying to use it, but it felt not quite right to merge into itself in the empty case?
Contributor
There was a problem hiding this comment.
prob fine to leave as-is
31a899c to
53d2123
Compare
Base automatically changed from
mitchellhenke/thread-safe-asset-sources
to
main
March 25, 2024 18:57
14f47f5 to
8cb13d2
Compare
added 3 commits
March 25, 2024 15:40
changelog: Internal, Performance, Refactor ScriptHelper class to be thread-safe
d9fc7c3 to
ee1ad6a
Compare
mitchellhenke
pushed a commit
that referenced
this pull request
Mar 26, 2024
This reverts commit 6d02f2e.
mitchellhenke
pushed a commit
that referenced
this pull request
Mar 26, 2024
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 of changes
Builds on #10301 to make
ScriptHelperexplicitly thread-safe as well usingRequestStore. The current usage is not necessarily thread-unsafe, but this refactors it to use the thread-safeRequestStoreto protect against future changes that may not be.