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

Add framework for preloading controllers #1614

Merged
merged 1 commit into from
Nov 28, 2020
Merged

Conversation

kraih
Copy link
Member

@kraih kraih commented Nov 28, 2020

Summary

This is a less ambitious solution for #1607. It doesn't preload all possible controllers but leaves it up to the developer to configure the right namespaces. The default of MyApp::Controller might just work for most of our users though.

Motivation

More efficient memory usage. Detecting syntax errors in controllers much earlier (during application startup instead of at runtime).

References

#1607

@kraih kraih requested a review from a team November 28, 2020 17:05
@amenonsen
Copy link
Contributor

For what it's worth, I read through this commit, and it looks good to me.

@Grinnz
Copy link
Contributor

Grinnz commented Nov 28, 2020

I like this approach especially as it can be easily configured to avoid preloading if someone was so inclined (e.g. CGI deployment).

Copy link
Member

@christopherraa christopherraa left a comment

Choose a reason for hiding this comment

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

👍

No objections from me. Surprised that this new functionality wasn't a bigger change.

@christopherraa
Copy link
Member

christopherraa commented Nov 28, 2020

One question as an after-thought: why default to MyApp::Controller? Does anyone really use that? If not, would it make more sense to default to whatever namespace the app is in, in the case of a full app? So if anyone has generated a Corp::App::Foo application, defaulting to preloading Corp::App::Foo::Controller::*. Too difficult or error-prone to detect perhaps?

@kraih
Copy link
Member Author

kraih commented Nov 28, 2020

When i say MyApp::Controller i of course mean "@{[ref $self]}::Controller" in code.

@mergify mergify bot merged commit ba49a8b into master Nov 28, 2020
Copy link
Member

@marcusramberg marcusramberg left a comment

Choose a reason for hiding this comment

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

I think this is a great addition to mojo. 👍

@jhthorsen jhthorsen deleted the controller_preloading branch November 30, 2020 03:37
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.

5 participants