PerlDancer / Dancer2

Perl Dancer Next Generation (rewrite of Perl Dancer)
http://perldancer.org/
Other
542 stars 274 forks source link

Feature/new config system #1636

Closed mikkoi closed 2 years ago

mikkoi commented 2 years ago

Completely new design for the config system.

Config are loaded by classes which implement the role Dancer2::Core::Role::ConfigReader. User can create custom classes to use instead of Dancer2::ConfigReader::FileSimple. Custom classes are activated via env var DANCER_CONFIG_READERS.

xsawyerx commented 2 years ago

I started reviewing this and stopped because it's a bit difficult. There are movements done between files with some renaming and I need to keep going back-and-forth to see what was moved, what was altered, etc. There is no explanation in the commit. I started with comments, then saw this was the original code copied, etc. I would have preferred this to be done either with several commits - each accomplishing one clear thing, or with a description with the commits of what they're doing. (Commits that both move code and change the code are some of the most difficult to properly review and that's when multiple commits are really useful.)

I'll start with a few small comments and try to review it more thoroughly meanwhile.

  1. I don't like the description "Ye Olde Config Reader." Many won't understand and it's not helpful.
  2. I don't like the name FileSimple. Other options: File::Simple, Simple::File, or just File.
xsawyerx commented 2 years ago

Here is partial coverage of what this PR does:

This feels like a bit of a maze and I'm still making sense of it. A map would be useful. :)

bigpresh commented 2 years ago

Thanks for the summarisation there @xsawyerx - definitely makes it easier for other reviewers, kudos.

In general, it seems like a good idea allowing much more flexibility in config reading - thanks @mikkoi for your work!

I'll try to review in more detail as soon as I get some free time.

I think it could do with a bit more documentation adding - i.e. documenting in the new D2::Core::ConfigReader::FileSimple that it is the original file-based config reader, and briefly documenting in D2::Core::Role::ConfigReader how to implement custom config readers based on it.

My understanding from a quick review is that the basic idea is for D2::Core::Role::Config to handle the "how to get config" stuff, and for D2::Core::Role::ConfigReader to be used by config readers, e.g. Dancer2::ConfigReader::FileSimple by default, to handle the actual reading of a config from a source. That seems like a pretty sane design.

mikkoi commented 2 years ago

I agree, it confuses when one commit has both file renames and changes. I created a new PR. Separated the commits and improved the docs a little. https://github.com/PerlDancer/Dancer2/pull/1637

Also removed "Ye Olde Config Reader." and renamed FileSimple to File::Simple.

mikkoi commented 2 years ago

I am wondering if I should have named Dancer2::Core::Role::ConfigReader something else. Now it confuses. Maybe ConfigBuilder, ConfigAssembler or ConfigCreator?

xsawyerx commented 2 years ago

I appreciate the new PR very much. I think we can close this one in favor of that. I was able to review it, provide comments, and a summary of what I think we should do next.

mikkoi commented 2 years ago

Development moved to https://github.com/PerlDancer/Dancer2/pull/1637