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

Add config module #33

Merged
merged 11 commits into from
Jul 24, 2024
Merged

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!

src/adapters/slack_client_adapter.rs Outdated Show resolved Hide resolved
@mattremmel mattremmel changed the title DRAFT (IN PROGRESS): Add config module Add config module Jul 23, 2024
@mattremmel mattremmel marked this pull request as ready for review July 23, 2024 15:02
@mattremmel mattremmel merged commit 36ee682 into planetary-social:main Jul 24, 2024
1 of 3 checks passed
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.

2 participants