-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Simplify Rails initialization to only be a mountable Engine #543
Comments
Makes sense to me. If something works only with Rails, I don't think there is any purpose to allow someone the option of loading the Engine class or not. The pattern I see most engines do -- and which I think (I think there is a lot of "legacy" stuff that doesn't always make complete sense in the Rails plugin/engine stuff, especially the docs, because they don't get a lot of attention from Rails maintainers. So there are some things, like the distinction between "plugin" and "engine" -- that don't really make a lot of sense, but are just kind of leftovers from the history, and the docs could probably use a large refactor too, but probably won't get it). |
My intention of splitting them was entirely about memory footprint. I didn't actually profile it (😬) but the intent was that if you were not using the Web Dashboard, your application would not incur the memory footprint cost of the Controllers/View Helpers/Cached ERB templates (not sure if these get preloaded/cached in production mode). I don't imagine it would be more than a few megabytes (again, I should actually profile it), but streamlining things for Heroku is always on my mind. |
Yeah, some things will probably get preloaded in production mode. Certainly any .rb files in As a heroku user myself, I doubt I'd think any RAM savings here (probably not too large) are worth any added complexity in maintenance or use, but okay, I see! If you ever need any Rails Engine features for something not related to the dashboard -- which seems plausible to me -- the approach of letting "load the Rails engine class" be a proxy for "load the dashboard" would start failing! In general, Rails is not so much about letting you selectively load features like this, but if you really wanted to, I wonder if there'd be another way, instead of avoiding loading the engine class, using Rails features to take your stuff out of the autoload paths or something. |
I appreciate your perspective on this. You're building up my sense that I should just turn it entirely into an Engine and move forward. |
Yeah, just my thoughts, it's probably fine either way! The real straightforward/natural way to make the dashboard be optional, and not loaded if not opted into... is to make it a separate gem! that an adopter can add to their Gemfile or not. That of course has it's own maintenance burden. |
Totally. I've been opinionated that if I'm maintaining it, it's going into GoodJob directly. I'd love for someone to lead on dogfooding a proper hook/plugin system for GoodJob though. |
👍 I like the idea of simplifying it. I can't imagine the memory overhead would be anything significant in its current state. Another option is to publish a separate gem (like In this case though, I think most people will (or should) want both, so I'm not sure the separation is necessary. |
Closed by #554. |
GoodJob currently is loaded in two parts:
require 'good_job'
which is implicitly loaded by Rails inBundler.require
require 'good_job/engine
which must be manually added to the Rails application.This happened because the Engine came 2nd and part of some initial reluctance on my part around the Web Dashboard, as well as my concerns about memory/code footprint of an Engine if the application was not explicitly using it. At this point though...
I think GoodJob should simply be an engine, and if one isn't using the Web Dashboard they simply would not mount the routes.
Some open questions:
The text was updated successfully, but these errors were encountered: