refactor(cli): centralize managed target preparation
Both client applets duplicated the step from parsed arguments to a runnable managed setup: target specs, managed target preparation, a ClientConfig built from an arbitrary primary target, pacing conversion, and an identical ManagedClientConfig skeleton with its own copy of the event-capacity constant. The primary-target step was the worst of it, since the managed driver replaces server_addr per target, so the address the applets went out of their way to find was immediately discarded. shared::client::prepare now performs that step once: it validates the target set first, then returns the validated targets, one target-free ClientConfig template, and the pacing, with managed_config()/managed_targets() for the driver. CommonClientArgs::to_client_config no longer takes a server address. Applet-specific semantics are unchanged: each command keeps its own duration default and help text, the client still accepts no target for --list-columns, and the TUI still rejects an empty target list at parse time.
This commit is contained in:
1 parent
c2666d776e
commit
50e4633c7a
8 files changed
+347
-128
No files matched your search
@@ -7,9 +7,13 @@ use super::args::CommonClientArgs;
|
||||
pub const DEFAULT_RECV_TIMEOUT: Duration = Duration::from_millis(20);
|
||||
|
||||
impl CommonClientArgs {
|
||||
pub fn to_client_config(&self, server: &str, duration: Duration) -> ClientConfig {
|
||||
/// Build the shared client configuration template for a managed run.
|
||||
///
|
||||
/// The template carries no server address: the managed driver replaces it
|
||||
/// per target from that target's configuration, so deriving one here from
|
||||
/// an arbitrary target would be dead data.
|
||||
pub fn to_client_config(&self, duration: Duration) -> ClientConfig {
|
||||
ClientConfig {
|
||||
server_addr: server.to_owned(),
|
||||
duration: (!duration.is_zero()).then_some(duration),
|
||||
interval: self.interval,
|
||||
length: self.length,
|
||||
|
||||
Reference in new issue
Block a user