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

Get rid of global state for config #48

Merged
merged 2 commits into from
Jan 6, 2025
Merged

Conversation

mtlynch
Copy link
Contributor

@mtlynch mtlynch commented Jan 5, 2025

Fixes #47

This refactors how we manage the configuration settings. Instead of loading them in conf and then sharing a variable in conf as global state, we read the configuration once from the main package and then pass the settings directly to the packages that consume them.

This makes it easier to reason about the code, as there is no more global state for configuration.

It feels a bit messy that the entire program has write access to the configuration as a shared global object. Shared globals make it more difficult to reason about a program's behavior.

This rewrite reduces the problem a bit by making the shared global state read-only after the client calls conf.Load.
@0x2E
Copy link
Owner

0x2E commented Jan 6, 2025

Thanks!

@0x2E 0x2E merged commit c424c2b into 0x2E:main Jan 6, 2025
1 check 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.

[FR] Get rid of conf as shared global state
2 participants