Skip to content

queue-runner: keep argument parsing out of the library crate#1798

Open
Ericson2314 wants to merge 1 commit into
masterfrom
queue-runner-new-cleanup
Open

queue-runner: keep argument parsing out of the library crate#1798
Ericson2314 wants to merge 1 commit into
masterfrom
queue-runner-new-cleanup

Conversation

@Ericson2314

Copy link
Copy Markdown
Member

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.

@Ericson2314 Ericson2314 force-pushed the queue-runner-new-cleanup branch from 2801074 to 957385a Compare June 17, 2026 17:25
`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.
@Ericson2314 Ericson2314 force-pushed the queue-runner-new-cleanup branch from 957385a to 5fe3de1 Compare June 17, 2026 19:54
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.

1 participant