diff --git a/zfctl/src/daemon_command.rs b/zfctl/src/daemon_command.rs index 9f86c09f..1d3174d7 100644 --- a/zfctl/src/daemon_command.rs +++ b/zfctl/src/daemon_command.rs @@ -73,7 +73,7 @@ pub(crate) enum DaemonCommand { #[command(verbatim_doc_comment)] #[command(group( ArgGroup::new("exclusive") - .args(&["id", "name"]) + .args(&["daemon_id", "daemon_name"]) .required(true) .multiple(false) ))] @@ -82,10 +82,10 @@ pub(crate) enum DaemonCommand { /// /// Note that if several daemons share the same name, the first to /// answer will be selected. - name: Option, + daemon_name: Option, /// The unique identifier of the Zenoh-Flow daemon to contact. #[arg(short = 'i', long = "id")] - id: Option, + daemon_id: Option, }, } @@ -155,8 +155,11 @@ impl DaemonCommand { println!("{table}"); } - DaemonCommand::Status { id, name } => { - let runtime_id = match (id, name) { + DaemonCommand::Status { + daemon_id, + daemon_name, + } => { + let runtime_id = match (daemon_id, daemon_name) { (Some(id), _) => id, (None, Some(name)) => get_runtime_by_name(&session, &name).await, (None, None) => { @@ -165,9 +168,9 @@ impl DaemonCommand { // any group. // (2) The `group` macro has `multiple = false` which indicates that only a single entry for // any group is accepted. - // (3) The `runtime_id` and `runtime_name` fields belong to the same group "runtime". + // (3) The `daemon_id` and `daemon_name` fields belong to the same group "exclusive". // - // => A single entry for the group "runtime" is required (and mandatory). + // => A single entry for the group "exclusive" is required (and mandatory). unreachable!() } }; @@ -189,7 +192,7 @@ impl DaemonCommand { .await .map_err(|e| { anyhow!( - "Failed to query Zenoh-Flow runtime < {} >: {:?}", + "Failed to query Zenoh-Flow daemon < {} >: {:?}", runtime_id, e ) diff --git a/zfctl/src/main.rs b/zfctl/src/main.rs index 6706abc1..a15628f6 100644 --- a/zfctl/src/main.rs +++ b/zfctl/src/main.rs @@ -69,7 +69,7 @@ enum Command { /// to contact. If no name or id is provided, one is randomly selected. #[command(group( ArgGroup::new("exclusive") - .args(&["runtime_id", "daemon_name"]) + .args(&["daemon_id", "daemon_name"]) .required(false) .multiple(false) ))] @@ -78,7 +78,7 @@ enum Command { command: InstanceCommand, /// The unique identifier of the Zenoh-Flow daemon to contact. #[arg(short = 'i', long = "id", verbatim_doc_comment)] - runtime_id: Option, + daemon_id: Option, /// The name of the Zenoh-Flow daemon to contact. /// /// If several daemons share the same name, `zfctl` will abort @@ -123,10 +123,10 @@ async fn main() -> Result<()> { match zfctl.command { Command::Instance { command, - runtime_id, + daemon_id, daemon_name, } => { - let orchestrator_id = match (runtime_id, daemon_name) { + let orchestrator_id = match (daemon_id, daemon_name) { (Some(id), _) => id, (None, Some(name)) => get_runtime_by_name(&session, &name).await, (None, None) => get_random_runtime(&session).await, diff --git a/zfctl/src/utils.rs b/zfctl/src/utils.rs index 6db3dea2..982d536e 100644 --- a/zfctl/src/utils.rs +++ b/zfctl/src/utils.rs @@ -18,14 +18,14 @@ use zenoh::{query::ConsolidationMode, Session}; use zenoh_flow_commons::RuntimeId; use zenoh_flow_daemon::queries::{selector_all_runtimes, RuntimeInfo, RuntimesQuery}; -/// Returns the list of [RuntimeInfo] of the reachable Zenoh-Flow Runtime(s). +/// Returns the list of [RuntimeInfo] of the reachable Zenoh-Flow Daemon(s). /// /// # Panic /// /// This function will panic if: -/// - (internal error) the query to list the Zenoh-Flow Runtimes could not be serialised by `serde_json`, +/// - (internal error) the query to list the Zenoh-Flow Daemons could not be serialised by `serde_json`, /// - the query on the Zenoh network failed, -/// - no Zenoh-Flow Runtime is reachable. +/// - no Zenoh-Flow Daemon is reachable. pub(crate) async fn get_all_runtimes(session: &Session) -> Vec { let value = serde_json::to_vec(&RuntimesQuery::List) .unwrap_or_else(|e| panic!("`serde_json` failed to serialize `RuntimeQuery::List`: {e:?}")); @@ -33,10 +33,10 @@ pub(crate) async fn get_all_runtimes(session: &Session) -> Vec { let runtime_replies = session .get(selector_all_runtimes()) .payload(value) - // We want to address all the Zenoh-Flow runtimes that are reachable on the Zenoh network. + // We want to address all the Zenoh-Flow daemons that are reachable on the Zenoh network. .consolidation(ConsolidationMode::None) .await - .unwrap_or_else(|e| panic!("Failed to query available runtimes:\n{:?}", e)); + .unwrap_or_else(|e| panic!("Failed to query available daemons:\n{:?}", e)); let mut runtimes = Vec::new(); while let Ok(reply) = runtime_replies.recv_async().await { @@ -56,7 +56,7 @@ pub(crate) async fn get_all_runtimes(session: &Session) -> Vec { if runtimes.is_empty() { panic!( - "No Zenoh-Flow runtime were detected. Have you checked if (i) they are up and (ii) \ + "No Zenoh-Flow daemon were detected. Have you checked if (i) they are up and (ii) \ reachable through Zenoh?" ); } @@ -64,13 +64,13 @@ pub(crate) async fn get_all_runtimes(session: &Session) -> Vec { runtimes } -/// Returns the unique identifier of the Zenoh-Flow Runtime that has the provided `name`. +/// Returns the unique identifier of the Zenoh-Flow Daemon that has the provided `name`. /// /// # Panic /// /// This function will panic if: -/// - there is no Zenoh-Flow Runtime that has the provided name, -/// - there are more than 1 Zenoh-Flow Runtime with the provided name. +/// - there is no Zenoh-Flow Daemon that has the provided name, +/// - there are more than 1 Zenoh-Flow Daemon with the provided name. pub(crate) async fn get_runtime_by_name(session: &Session, name: &str) -> RuntimeId { let runtimes = get_all_runtimes(session).await; let mut matching_runtimes = runtimes @@ -79,14 +79,14 @@ pub(crate) async fn get_runtime_by_name(session: &Session, name: &str) -> Runtim .collect_vec(); if matching_runtimes.is_empty() { - panic!("Found no Zenoh-Flow Runtime with name < {name} >"); + panic!("Found no Zenoh-Flow Daemon with name < {name} >"); } else if matching_runtimes.len() > 1 { - tracing::error!("Found multiple Zenoh-Flow Runtimes named < {name} >:"); + tracing::error!("Found multiple Zenoh-Flow Daemons named < {name} >:"); matching_runtimes.iter().for_each(|&r_info| { tracing::error!("- {} - (id) {}", r_info.name, r_info.id); }); panic!( - "There are multiple Zenoh-Flow Runtimes named < {name} >, please use their 'id' \ + "There are multiple Zenoh-Flow Daemons named < {name} >, please use their 'id' \ instead" ); } else { @@ -94,14 +94,14 @@ pub(crate) async fn get_runtime_by_name(session: &Session, name: &str) -> Runtim } } -/// Returns the unique identifier of a reachable Zenoh-Flow Runtime. +/// Returns the unique identifier of a reachable Zenoh-Flow Daemon. /// /// # Panic /// /// This function will panic if: -/// - (internal error) the query to list the Zenoh-Flow Runtimes could not be serialised by `serde_json`, +/// - (internal error) the query to list the Zenoh-Flow Daemons could not be serialised by `serde_json`, /// - the query on the Zenoh network failed, -/// - no Zenoh-Flow Runtime is reachable. +/// - no Zenoh-Flow Daemon is reachable. pub(crate) async fn get_random_runtime(session: &Session) -> RuntimeId { let mut runtimes = get_all_runtimes(session).await; let orchestrator = runtimes.remove(rand::thread_rng().gen_range(0..runtimes.len()));