-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert supervisor config to global singleton
This commit converts to using a global singleton for configuration, rather than threading a reference to everything that needs configuration data. Since we need to populate our `Config` struct with data from `clap`, we need to be able to modify it at runtime with an argument, rather than simply use `lazy_static!`. This implementation stores the configuration as a static pointer to a location on the heap via `Box`, and updates the pointer via `mem::transmute` in a `gcache()` method. This method is called early in `main` - right after we populate the configuration struct, in fact. Once `gcache()` has been called (one time only; subsequent calls will be ignored), you can access the `Config` struct through the `config::gconfig()` method. This removes all the references to threading an `&Config` through the code base, and replaces them with calls to `gconfig()`. In particular, it cleans up the need for lifetimes in the topology and worker code, which is a nice side effect. Signed-off-by: Adam Jacob <[email protected]>
- Loading branch information
Showing
9 changed files
with
133 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.