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