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

DRAFT (IN PROGRESS): Add config module #33

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mattremmel
Copy link
Collaborator

No description provided.

@mattremmel
Copy link
Collaborator Author

@dcadenas heres the way I usually set up a config module for my projects. I inlined an example of using the config, but usually I would have that in the same module as the object/actor that needs the config. Its a pretty minimal example, but I would also be happy to show you some more 'real' examples of how I've used it in one of our production monitors.

@mattremmel
Copy link
Collaborator Author

The main benefit, is that all the configuration can be loaded and parsed at startup, so that you can fail fast, and code that depends on that config are able to be made infallible, since the fallible fetching and parsing the config was already done before its construction. It also helps to make all the config typesafe once you go to use it.

@mattremmel
Copy link
Collaborator Author

I forgot to mention. This allows easily overlaying a default config, with an environment based file config thats dynamically loaded based on environment variable, then a local config which is added to .gitignore, so that you can put keys/etc into there, and then any config item can be overwritten with an environment variable, which has the highest precedence.

Copy link
Contributor

@dcadenas dcadenas left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -31,10 +46,9 @@ impl SlackClientPortBuilder for SlackClientAdapterBuilder {
}

impl SlackClientAdapter {
// TODO: This is infallible now
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

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.

None yet

2 participants