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/remove default engine config #578

Closed
wants to merge 7 commits into from

Conversation

xsawyerx
Copy link
Member

This is what I refer to in issue #577.

Commit message of the actual work commit:

Remove default engine configuration:

Default engine configurations are configurations that are
automatically sent to every engine. This makes no sense, because
each engine will have its own configuration.

An example would be a template engine that has a template object
inside it. The template object gets sent the default configuration.

The default configuration contains two keys - environment and
location - which either means nothing to the template object, or
it means something probably different.

Instead, these should be sent as attributes to the engines. They
can be configured in the Engine role and automatically fed. Thing
is, I couldn't find anything that actually uses them and needs
them, so I removed it completely.

@veryrusty
Copy link
Member

It would be nice to see those two attribute go (including their definitions from Role::Engine).

However; digging through the commit history, they were added in 82f4574, with the next commit (eb2a509) adding Dancer2::Logger::File, which looks like it still uses those two attributes (directory and filename of the log file) in the latest release. I can't see any tests for Logger::File though :(

@xsawyerx
Copy link
Member Author

I'm happy you found this problem. I can now fix it.

I already added what should be a fix for the travis build fail.

@xsawyerx
Copy link
Member Author

I think I fixed it. @veryrusty, what do you think?

@veryrusty
Copy link
Member

@xsawyerx sorry it took so long to review this. Agree that the defaults for location and environment in Logger::File is horrid; but its a better alternative than having those attributes as part of the engine (in my opinion). They should be lazy attributes (see 1c10ea2) as they are only needed if a Logger::File instance is created without log_dir or file_name specified.

This will also help resolve other outstanding issues, like #520.

xsawyerx added a commit that referenced this pull request May 20, 2014
In GH #578, Russell explains that if the File logger
(Dancer2::Logger::File) is created with a declared log_dir and file_name,
these attributes aren't used or needed. We save memory/CPU on this. Why not?
@xsawyerx
Copy link
Member Author

@veryrusty Updated with the change you suggested.

Do you think we're good to go? We should probably write tests for it.

Default engine configurations are configurations that are
automatically sent to every engine. This makes no sense, because
each engine will have its own configuration.

An example would be a template engine that has a template object
inside it. The template object gets sent the default configuration.

The default configuration contains two keys - environment and
location - which either means nothing to the template object, or
it means something probably different.

Instead, these should be sent as attributes to the engines. They
can be configured in the Engine role and automatically fed. Thing
is, I couldn't find anything that actually uses them and needs
them, so I removed it completely.
Perl 5.18 doesn't like us setting $_, so we change it to a more
explicit - yet not as nice - code.
…ults:

Dancer2::Logger::File actually needs the attributes environment/location
which we removed in this branch. It is set in the Engine role.

This commit does two things:
1. Put those attributes in the File logger module
2. Give them the proper values using the App via the Context

The 2nd item is the most horrible way of doing it. I'm not sure how else
to do it, but it will need to be changed as part of the Context decoupling
work which is something we definitely want to do.
In GH #578, Russell explains that if the File logger
(Dancer2::Logger::File) is created with a declared log_dir and file_name,
these attributes aren't used or needed. We save memory/CPU on this. Why not?
@veryrusty
Copy link
Member

I've had another look over this (in a very sleep deprived state). Giving it a 👍, though more tests would be better 😄

@xsawyerx
Copy link
Member Author

Let's make sure we add some tests for it before merging. I'm gonna mark it as beginner friendly so anyone who wants to help with the tests could.

xsawyerx added a commit that referenced this pull request May 26, 2014
In GH #578, Russell explains that if the File logger
(Dancer2::Logger::File) is created with a declared log_dir and file_name,
these attributes aren't used or needed. We save memory/CPU on this. Why not?
@xsawyerx
Copy link
Member Author

Added tests and merged!

@xsawyerx xsawyerx closed this May 26, 2014
@xsawyerx xsawyerx deleted the fix/remove-default-engine-config branch May 26, 2014 21:41
@veryrusty
Copy link
Member

👯 @xsawyerx++

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

Successfully merging this pull request may close these issues.

2 participants