refactor(agent): drop vestigial install_configured param, non_empty_env helper, explicit infallible expect in client
This commit is contained in:
parent
9cebc128e2
commit
f2f104627d
4 changed files with 14 additions and 15 deletions
|
|
@ -429,7 +429,7 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
||||||
// through `<parent>` via the `send_to_parent` failure-notify path.
|
// through `<parent>` via the `send_to_parent` failure-notify path.
|
||||||
// The broker resolves `<parent>` per `topology::parent_of`;
|
// The broker resolves `<parent>` per `topology::parent_of`;
|
||||||
// root agents fall through to operator.
|
// root agents fall through to operator.
|
||||||
for failure in plugins::install_configured(socket).await {
|
for failure in plugins::install_configured().await {
|
||||||
S::send_to_parent(socket, failure).await;
|
S::send_to_parent(socket, failure).await;
|
||||||
}
|
}
|
||||||
tokio::spawn(hive_ag3nt::forge_notify::run(socket.to_path_buf()));
|
tokio::spawn(hive_ag3nt::forge_notify::run(socket.to_path_buf()));
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(last_err.unwrap_or_else(|| anyhow!("hive socket: retries exhausted")))
|
// Reaching here means the final attempt returned `Transient`, which always
|
||||||
|
// sets `last_err` — so this is infallible.
|
||||||
|
Err(last_err.expect("a transient failure on the final attempt set last_err"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transient = connect / IO error worth a retry (server restart, broken
|
/// Transient = connect / IO error worth a retry (server restart, broken
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,18 @@ pub fn label() -> String {
|
||||||
env::var("HIVE_LABEL").unwrap_or_default()
|
env::var("HIVE_LABEL").unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `env::var(key)` reduced to `Some(value)` only when the var is set and
|
||||||
|
/// non-empty — the shared shape of the hive/swarm display-name lookups below.
|
||||||
|
fn non_empty_env(key: &str) -> Option<String> {
|
||||||
|
env::var(key).ok().filter(|s| !s.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
/// The hive's canonical DNS domain when set, otherwise None. Single-hive
|
/// The hive's canonical DNS domain when set, otherwise None. Single-hive
|
||||||
/// deployments where `HYPERHIVE_HIVE_DOMAIN` is unset return None — callers
|
/// deployments where `HYPERHIVE_HIVE_DOMAIN` is unset return None — callers
|
||||||
/// then degrade gracefully to the short label.
|
/// then degrade gracefully to the short label.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hive_domain() -> Option<String> {
|
pub fn hive_domain() -> Option<String> {
|
||||||
env::var("HYPERHIVE_HIVE_DOMAIN")
|
non_empty_env("HYPERHIVE_HIVE_DOMAIN")
|
||||||
.ok()
|
|
||||||
.filter(|s| !s.is_empty())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Human display name of this hive (e.g. `pr1ma`). Distinct from
|
/// Human display name of this hive (e.g. `pr1ma`). Distinct from
|
||||||
|
|
@ -32,9 +36,7 @@ pub fn hive_domain() -> Option<String> {
|
||||||
/// at their discretion.
|
/// at their discretion.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hive_name() -> Option<String> {
|
pub fn hive_name() -> Option<String> {
|
||||||
env::var("HYPERHIVE_HIVE_NAME")
|
non_empty_env("HYPERHIVE_HIVE_NAME")
|
||||||
.ok()
|
|
||||||
.filter(|s| !s.is_empty())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Human display name of the wider swarm this hive belongs to (e.g.
|
/// Human display name of the wider swarm this hive belongs to (e.g.
|
||||||
|
|
@ -43,9 +45,7 @@ pub fn hive_name() -> Option<String> {
|
||||||
/// `services.hyperhive.swarmName` option is unset.
|
/// `services.hyperhive.swarmName` option is unset.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn swarm_name() -> Option<String> {
|
pub fn swarm_name() -> Option<String> {
|
||||||
env::var("HYPERHIVE_SWARM_NAME")
|
non_empty_env("HYPERHIVE_SWARM_NAME")
|
||||||
.ok()
|
|
||||||
.filter(|s| !s.is_empty())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One peer hive in the same swarm. Parsed from `HYPERHIVE_PEERS`.
|
/// One peer hive in the same swarm. Parsed from `HYPERHIVE_PEERS`.
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@
|
||||||
//! plugin specs resolve against current index data. Marketplace update
|
//! plugin specs resolve against current index data. Marketplace update
|
||||||
//! failures are non-fatal — stale index is better than no install attempt.
|
//! failures are non-fatal — stale index is better than no install attempt.
|
||||||
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
const PLUGINS_PATH: &str = "/etc/hyperhive/claude-plugins.json";
|
const PLUGINS_PATH: &str = "/etc/hyperhive/claude-plugins.json";
|
||||||
|
|
@ -103,8 +101,7 @@ async fn update_marketplaces() {
|
||||||
/// notification, see `Surface::send_to_parent`). Wire-agnostic: the
|
/// notification, see `Surface::send_to_parent`). Wire-agnostic: the
|
||||||
/// caller picks the recipient via the same `<parent>` sentinel that
|
/// caller picks the recipient via the same `<parent>` sentinel that
|
||||||
/// failure-notify uses everywhere else.
|
/// failure-notify uses everywhere else.
|
||||||
pub async fn install_configured(socket: &Path) -> Vec<String> {
|
pub async fn install_configured() -> Vec<String> {
|
||||||
let _ = socket; // Reserved for future telemetry; currently unused.
|
|
||||||
let Ok(raw) = tokio::fs::read_to_string(PLUGINS_PATH).await else {
|
let Ok(raw) = tokio::fs::read_to_string(PLUGINS_PATH).await else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue