-
Notifications
You must be signed in to change notification settings - Fork 23
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
Configurable env parser #151
Conversation
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.
Very very nice, just minor comments and perhaps a need for documenting the new possibility to configure the parser module
?LOG_ERROR("cannot parse environment variable, using default value.~n" | ||
" parsing error: '~p'~n" | ||
" variable name: '$~s'~n" | ||
" variable value: '~s'~n" | ||
" default value: '~p'~n", |
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.
Now that I see these, can we use structured logging? Like, maps with keys and values. Maybe in a separate PR if there's plenty of these things anyway.
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.
I think it's worth to have a separate dedicated PR with all the logs reworked.
-type mfa(Arity) :: {module(), atom(), Arity}. | ||
-type verification_method() :: none | one_of() | mfa(1) | verification_fun(). | ||
-type update_method() :: read_only | none | mfa(2) | update_fun(). |
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.
Excellent idea
|
||
-include_lib("kernel/include/logger.hrl"). | ||
|
||
-define(DEFAULT_PARSER_MODULE, amoc_config_parser). | ||
|
||
-callback(parse_value(string()) -> {ok, amoc_config:value()} | {error, any()}). |
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.
This is a perfect idea, but it only requires now documentation on how to do so when you want to add a different parser. So some md file in the guides directory, link it in the rebar config for hex like the others, etc.
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.
I think we need a separate dedicated PR with documentation update.
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.
LGTM 👌🏽
This PR introduces the following changes:
• Possibility to customise parsing (de-serialisation) logic for env variables.
• small improvements for
amoc_config_scenario:update_settings/1
logic.• extension of the tests.