queue-runner: keep argument parsing out of the library crate#1798
Open
Ericson2314 wants to merge 1 commit into
Open
queue-runner: keep argument parsing out of the library crate#1798Ericson2314 wants to merge 1 commit into
Ericson2314 wants to merge 1 commit into
Conversation
2801074 to
957385a
Compare
`State` stored the whole clap-derived `Cli`, and `State::new` parsed argv (`Cli::new()`) and read the config file (`App::init`) itself. Because `config.rs` and `State` live in the library crate (consumed by the examples), that pulled `clap` and the entire argv surface into the library's compilation unit, even though the library only ever needs the mTLS material from those arguments. Split it along what each side actually uses: - The library keeps a plain, clap-free `MtlsConfig` (the gRPC server's only need from the CLI). `State` holds that instead of `Cli`, and `State::new(mtls, config)` takes both as values rather than reaching out to argv and the filesystem. - A new binary-only `cli` module owns `Cli`, `BindSocket`, and the `clap::Parser` derive. `main` parses the arguments, loads the config, lifts out `cli.mtls()`, and injects everything into `State::new`. The config-path used by the SIGHUP reloader is threaded through from `main` rather than read back off `State`. `clap` is now referenced only from `src/cli.rs`, which is not part of the library, so the library (and `examples/collect-fods`) compile without it. The unused `env` clap feature is dropped while we're here.
957385a to
5fe3de1
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Statestored the whole clap-derivedCli, andState::newparsed argv (Cli::new()) and read the config file (App::init) itself. Becauseconfig.rsandStatelive in the library crate (consumed by the examples), that pulledclapand the entire argv surface into the library's compilation unit, even though the library only ever needs the mTLS material from those arguments.Split it along what each side actually uses:
The library keeps a plain, clap-free
MtlsConfig(the gRPC server's only need from the CLI).Stateholds that instead ofCli, andState::new(mtls, config)takes both as values rather than reaching out to argv and the filesystem.A new binary-only
climodule ownsCli,BindSocket, and theclap::Parserderive.mainparses the arguments, loads the config, lifts outcli.mtls(), and injects everything intoState::new. The config-path used by the SIGHUP reloader is threaded through frommainrather than read back offState.clapis now referenced only fromsrc/cli.rs, which is not part of the library, so the library (andexamples/collect-fods) compile without it.