Skip to content

Refactor AssetSources to be thread-safe#10301

Merged
mitchellhenke merged 3 commits intomainfrom
mitchellhenke/thread-safe-asset-sources
Mar 25, 2024
Merged

Refactor AssetSources to be thread-safe#10301
mitchellhenke merged 3 commits intomainfrom
mitchellhenke/thread-safe-asset-sources

Conversation

@mitchellhenke
Copy link
Copy Markdown
Contributor

🛠 Summary of changes

AssetSources is currently initialized on boot and not modified afterwards (unless in development). The issue is it's use of the instance variable in class method. This PR refactors them out to be instance variables on an instance of the class that is assigned to the application configuration.

(Somewhat related to #10300)

@mitchellhenke mitchellhenke requested a review from a team March 25, 2024 17:15
Copy link
Copy Markdown
Contributor Author

@mitchellhenke mitchellhenke Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a slight change in behavior to avoid changing the values of the instance outside of instantiation when caching is enabled

Mitchell Henke added 2 commits March 25, 2024 12:26
changelog: Internal, Performance, Refactor AssetSources class to be thread-safe
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/thread-safe-asset-sources branch from 13ac05b to 8fd5e53 Compare March 25, 2024 17:27
Copy link
Copy Markdown
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but of teeny little things but LGTM! none of them showstoppers

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/thread-safe-asset-sources branch from 31a899c to 53d2123 Compare March 25, 2024 18:27
@mitchellhenke mitchellhenke merged commit 25d82a4 into main Mar 25, 2024
@mitchellhenke mitchellhenke deleted the mitchellhenke/thread-safe-asset-sources branch March 25, 2024 18:57
Copy link
Copy Markdown
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

def initialize(manifest_path:, cache_manifest:, i18n_locales:)
@manifest_path = manifest_path
@cache_manifest = cache_manifest
@regexp_locale_suffix = %r{\.(#{i18n_locales.join('|')})\.js$}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a decent microoptimization to avoid creating this pattern every time we call get_sources 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants