-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
♻️ Implement a config macro to simplify stump_config.rs
#397
Conversation
Codecov ReportAttention: Patch coverage is
|
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.
To the best of my ability, I think this looks good! I am very unfamiliar with macros. Thanks for adding this!!
I'm going ahead and approving this, but I likely won't include it as part of 0.0.5
. I've already cut that release branch and plan to push it out today (was going to do it yesterday but then that GitHub outage happened). If I have to delay the release until the weekend, I'll include it though 🙂
stump_config.rs
Don't delay the release, I'd like to do a bit more work on this and mainly put the pull request up for review purposes. I'd like to add better error handling to the macro so that it properly highlights the cause of errors instead of panicking and highlighting the entire input. I also noticed that it causes something to happen with the verbosity setting that differs from before this change - it turns off all logging (which results from verbosity = 0, the default) but prior to this change verbosity on dev instances of the server would be set to 1. Not sure what the interaction is there and I need to investigate a bit before we merge to avoid nightly users having empty logs. |
I mostly meant if something came up that made me have to delay 😅 but no problem! I'll re-request myself for review and mark it as draft until you're ready for me to take another look. Hopefully by then I'll have had the time to get a little more acquainted with macros. If you need anything during your investigation give me a shout! |
I've made a few more additions, namely adding some documentation to the macro and adding a set of integration tests that fill the role of several tests on Assuming everything looks good, this should be ready to merge. |
Although I like the way that
StumpConfig
works (taking a file, layering the environment on that, etc.), I think it was pretty cumbersome to update, requiring a lot of little edits throughout the file to add a single variable. There's no reason for that to be the case given Rust's macro system.I wrote a procedural macro that takes an annotated struct as input and generates something functionally identical to the current contents of stump_config.rs, but many lines shorter. Better still, adding new variables should only take a few lines added to the struct definition. I'm pretty pleased with this one.
It passes all of the tests, which I suspect could be simplified as well.