Skip to content
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

Fix Reloader #146

Closed
3 tasks done
karloscarweber opened this issue May 5, 2023 · 3 comments
Closed
3 tasks done

Fix Reloader #146

karloscarweber opened this issue May 5, 2023 · 3 comments

Comments

@karloscarweber
Copy link
Member

karloscarweber commented May 5, 2023

The Reloader is broken or borked with the way we do things now in Camping land. We need to fix that, I think.

This issue entails a couple things really. Additionally we want to have a standard directory structure that we've been experimenting with for a while now. So we should have that sorted out. We need to cement the convention of using camp.rb as the launcher for our apps. OR moving apps up to an /apps directory and autoloading THOSE virtually or something. We also ought to add some autoloader stuff using Zeitwerk.

So:

  • Establish and document a directory structure.
  • Add Autoloading of Constants using Zeitwerk.
  • Fix reloader in development finally.
@karloscarweber
Copy link
Member Author

I've been experimenting with this a bit over the weekend and I wanted to share.

Reloader

Camping's reloader assumes that we're loading every app from a single file, which kinda makes sense, historically. This is not going to be the assumption moving forward though, and with autoloading we'll need to rethink this. To really understand what to do we'll need to establish a directory structure scheme, that's simple, and easy to understand.

Directory Structure.

We've talked about this in other issues and PRs, but a formal directory structure should now be like this:

Gemfile
Rakefile
camp.rb
config.kdl
src/
lib/
public/
test/
apps/
    camping.rb
    controllers/
    views/
    models/
    helpers/
    nuts/
        nuts.rb
        controllers/
        views/
        models/
        helpers/

I think that's an expanded directory structure. An abbreviated structure:

Gemfile
Rakefile
camp.rb
config.kdl
src/
lib/
public/
test/

Because, ideally, you would only have an Apps directory if you have more than one app, or if you're app starts to get pretty big.

A goal of Camping is to have installable and modifiable apps available. So you could add an app to your Gemfile and just, have it work. Getting that to work with the Reloader might be tricky, but not if we reload according to where the app is defined, i.e. : Camping.goes :Nuts. At that moment the reloader, wherever it is, needs to be informed that we've got a new Camping app defined. The assumed directory structure is, well, assumed, and we load the app accordingly.

Once everything is loaded Camping.make_camp is Called. This sets up routes for the controllers. So that's what we'll do, start by adding the location of where something 'Camping.goes` to the reloader, and making a list of these things.

@karloscarweber
Copy link
Member Author

I've mostly got a new reloader thing working the way It ought to on this branch: https://github.com/karloscarweber/camping/tree/feat-146-fix-reloader .

Formal PR and more documentation/discussion about this should be incoming later tonight/early tomorrow.

@karloscarweber
Copy link
Member Author

karloscarweber commented Jun 1, 2023

I have a new Reloader now called Loader mostly working and passing tests. Work in progress PR can be found at: #147 .

I have questions about the ORDER that things should be loaded or autoloaded. For example in directories and subdirectories should we prioritize the eager loading of Models over Controllers? Ought there to be a preloading sequence for initializers? I'd love to hear what ya'll think about those ideas.

Should certain files/folders be loaded first, or take priority?

The idea is that certain files or folders should be loaded first as they are probably depended on by other files, like models. But this might be a non issue because of the ZeitWerk loading thingy. Each Loader instance has an its /apps and /lib folder autoloaded.

Related question! Should /lib be autoloaded?

Pre and Post loading scripts?

Before loading our apps should we have some sort of initialization scripts? I don't want to bloat things and perhaps the config.kdl or camp.rb files are fine for preloading things. But let's say we add this, we should add them to a folder named: /kindling.

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

No branches or pull requests

1 participant