-
Notifications
You must be signed in to change notification settings - Fork 277
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
Feature/new config system (improved) #1637
base: main
Are you sure you want to change the base?
Conversation
d9901f7
to
dfd9ced
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the way you see it is:
- The
App
now usesRole::Config
- The role
Role::Config
hasconfig_readers
andconfig_files
- Each of the Config Reader classes consumes
Role::ConfigReader
- Each of these classes also has its own
config_files
which they merge together - The
Role::Config
will then merge these "merged" config files into its ownconfig_files
and its configuration itself, which then the App is able to use
Did I understand this right?
This makes sense, but it also suffers from the assumption that all configurations are files, so while it's more abstract it's - and I'm sorry to say this - not abstract enough.
The naming for Role::Config
and Role::ConfigReader
and ConfigReader
gave me a bit of confusion trying to grok this.
I'm also missing the role HasLocation
. I don't see where it went. Is it no longer necessary because the location is sent through the App to Role::Config
?
I think this warrants further discussion because I don't think we should merge this when it's halfway between being too rigid and not being flexible enough. Once you could correct whatever I got wrong, I'm happy to propose an improved structure.
lib/Dancer2/Core/Role/Config.pm
Outdated
@@ -84,9 +91,11 @@ has global_triggers => ( | |||
}, | |||
}; | |||
|
|||
no warnings 'once'; # Disable: Name "Dancer2::runner" used only once: possible typo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worthwhile exploring this warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seconded.
lib/Dancer2/Core/Role/Config.pm
Outdated
to manage the Dancer2 configuration. | ||
|
||
It is now possible for user to control which B<ConfigReader> | ||
class to use to create the config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Users can control which B class to use when creating the config."
Same comment as above.
lib/Dancer2/Core/Role/Config.pm
Outdated
my $runner_config = defined $Dancer2::runner | ||
? Dancer2->runner->config | ||
: {}; | ||
use warnings 'once'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be easier to write:
my $runner_config;
{
no warnings 'once';
$runner_config = defined $Dancer2::runner
? Dancer2->runner->config
: {};
}
I would still want to know if we could avoid that warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reformatted.
Yes, precisely. Again the same applies to HasLocation. Location is deduced once and then passed on to the config readers. Just like environment name. |
I think calculating I think the usage of roles here might be too much. How about:
Two things left in mind:
|
If we ditch The name is bad but I like the idea that the
I don't think its possible. For the same reason I couldn't use hooks. It creates a dependency on user code before App is ready - and config should be read and ready before App is accessible for users.
Agree. Too many moving parts for the moment. |
Incompatible with what?
Sorry, I don't understand your comment here. |
Attribute Just thinking that I like the idea that the config readers maintain a list of files or sources where the config is read from. |
I can't imagine this being used for anything. The Config Reader is a role composed into classes. If someone is using it, that's not in a way that we should worry about officially supporting.
It makes sense if the specific sense of configuration as files, but in the abstract sense of configuration as values by keys, files are a secondary - and more important, optional - concept. |
The only thing someone could be using this for, I'd think, is logging the contents of what's there (and that is already happening on app startup). Maybe some devs got clever with the contents. We could remove it and see who complains, or for non-file based configs (etcd, Vault, wherever else you might pull config from) we could put a one-line description in about where the config came from. Personally, I'd rather remove it, make a developer release, document the removal, and see who complains.
As do I. I am not sure what I'd do with that info yet, but having it is intriguing. If only for some debugging purposes down the road. |
dfd9ced
to
3eb359f
Compare
I have changed all the small things and I removed the attribute |
@xsawyerx Or else, we could redesign the whole thing so that Config and ConfigReader have nothing to do with each other, except that configuration is something that ConfigReader produces and then gives/assigns to Config. It seems like a very big change. |
I do think we need to make such a big change and I don't think this big change is this "big." Of course, I could be wrong about that. (But it would still be the right thing to do.) |
3eb359f
to
c99b4b4
Compare
To be on the safe side, I rebased the branch from master. So I had to force push. The new commits are:
The main changes are: |
The test |
Role::Config is the configuration part of an object Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Remove everything that has to do with loading config from files or elsewhere. Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Create Dancer2::Core::Role::ConfigReader and Dancer2::ConfigReader::File::Simple. Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Also specify lazy => 1. Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
* Remove previously commented out code * Remove 'use Data::Dumper' Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
fda4ed3
to
35ad849
Compare
The tests now run. |
No description provided.