fix broadcast send for manager, deduplicate into coordinator.broadcast_send
This commit is contained in:
parent
f3739d2b8e
commit
1a36c38a54
3 changed files with 45 additions and 25 deletions
|
|
@ -192,6 +192,27 @@ impl Coordinator {
|
|||
}
|
||||
}
|
||||
|
||||
/// Deliver `body` to every currently-registered agent, appending the
|
||||
/// standard broadcast hint. Returns a list of per-agent error strings
|
||||
/// for any that failed (empty = all ok). The sender's own inbox is
|
||||
/// included — the hint text tells agents to ignore if no action needed.
|
||||
pub fn broadcast_send(&self, from: &str, body: &str) -> Vec<String> {
|
||||
const HINT: &str =
|
||||
"\n\n⚠️ _hint: this was a broadcast and may not need any action from you_";
|
||||
let broadcast_body = format!("{body}{HINT}");
|
||||
let mut errors = Vec::new();
|
||||
for agent_name in self.list_agents() {
|
||||
if let Err(e) = self.broker.send(&hive_sh4re::Message {
|
||||
from: from.to_owned(),
|
||||
to: agent_name.clone(),
|
||||
body: broadcast_body.clone(),
|
||||
}) {
|
||||
errors.push(format!("{agent_name}: {e}"));
|
||||
}
|
||||
}
|
||||
errors
|
||||
}
|
||||
|
||||
pub fn agent_dir(name: &str) -> PathBuf {
|
||||
PathBuf::from(format!("{AGENT_RUNTIME_ROOT}/{name}"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue