-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components registry safe reload #5780
Components registry safe reload #5780
Conversation
93a8d30
to
c1826d7
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5780 +/- ##
=======================================
Coverage 88.72% 88.73%
=======================================
Files 712 713 +1
Lines 16914 16924 +10
=======================================
+ Hits 15007 15017 +10
Misses 1907 1907 ☔ View full report in Codecov by Sentry. |
83ef1ac
to
4005895
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loving where this is going, but we should give caching a try IMO.
The Rails guide even says:
Bottom line: do not cache reloadable classes or modules.
Is there a way to use Zeitwerk for the cache? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. You are right. I think we can tackle the caching part in another PR. We haven't have caching before. So, this is already an improvisation. Thanks
This adds a new `ComponentRegistry` class that allows: - setting component classes as strings (to allow for easy reloading) - getting nice errors when requesting components that don't exist - getting nice errors when setting a component to a non-existing class It also moves some of the logic from `SolidusAdmin::Configuration` into a separate class. I've decided not to add memoization here as I'm not sure this would make a giant difference performance-wise, and also the Rails Guide on Reloading constants very clearly says: ``` Bottom line: do not cache reloadable classes or modules. ```
4005895
to
0408942
Compare
Rebased on |
Summary
In a Zeitwerk world, we can't use reloadable constant in initializers.
This moves the constantization of the names of components into a new
ComponentRegistry
class.This PR is build on top of #5779 so that the theory can directly be tested. Really relevant is only the second commit here.