Use get_config_value for Rouille configurations #109
No reviewers
Labels
No Label
bug
documentation
duplicate
enhancement
help wanted
invalid
maintenance
peach-lib
peach-network
peach-oled
peach-stats
peach-web
question
refactor
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: PeachCloud/peach-workspace#109
Loading…
Reference in New Issue
No description provided.
Delete Branch "get-config"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR is basically the minimum change to use the new get_config_value for "STANDALONE_MODE", "DISABLE_AUTH", "ADDR", "PORT"
I changed the name of CONFIG to ROUILLE_CONFIG, to hopefully make it more clear that ROUILLE_CONFIG is actually just a subset of the total configurations (and is ultimately getting it from the same source).
Alternatively we could delete peach-web/src/config.rs,
and change all the specific places that use a config value to call get_config_value in line. But I thought, this works, and is actually more performant (just loads these four particular config values once, on server startup), so maybe its fine.
wait actually im updating this so defaults arent declared in two places -- thats a bit misleading
Ok now I've updated this PR so that default values are only declared in peach-lib::config_manager (I think this is less confusing than having a second pair of defaults also defined in peach-web for these specific four values).
Currently I use an expect in lazy_static in peach-web::main if loading RouilleConfig doesn't work -- I imagine we want some type of configuration (even if its default values) and if even default values can't load, then maybe the server can't run.
It would be unfortunate if a permissions issue on config.yml caused an illegibile error. One idea: in a separate PR, we could change line 84 of config_manager.rs so that if its unable to load config.yml from disc, it just returns the default value, instead of raising an error... I'm not totally sure which is preferrable (using a default value when there is an error loading config.yml, or bubbling up that error...)
A couple thoughts here:
SERVER_CONFIG
orWEBSERVER_CONFIG
instead ofROUILLE_CONFIG
, ie. name it after the role and not the libraryconfig.yml
from disc (in this case I think it's better to clearly communicate the error rather than papering over it, especially since file permissions are quite a fundamental thing and outside of the code itself)cool, just pushed the change (was also thinking about these names)
makes sense, returning an error is currently what we're doing
logging/propagating errors in a way that we can give useful info to the User and to feed back to the developers I think still needs works but it outside of the scope of this PR
🟢