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
|
|
@ -85,16 +85,29 @@ fn manager_recv_timeout(wait_seconds: Option<u64>) -> std::time::Duration {
|
|||
#[allow(clippy::too_many_lines)]
|
||||
async fn dispatch(req: &ManagerRequest, coord: &Arc<Coordinator>) -> ManagerResponse {
|
||||
match req {
|
||||
ManagerRequest::Send { to, body } => match coord.broker.send(&Message {
|
||||
from: MANAGER_AGENT.to_owned(),
|
||||
to: to.clone(),
|
||||
body: body.clone(),
|
||||
}) {
|
||||
Ok(()) => ManagerResponse::Ok,
|
||||
Err(e) => ManagerResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
},
|
||||
ManagerRequest::Send { to, body } => {
|
||||
if to == "*" {
|
||||
let errors = coord.broadcast_send(MANAGER_AGENT, body);
|
||||
if errors.is_empty() {
|
||||
ManagerResponse::Ok
|
||||
} else {
|
||||
ManagerResponse::Err {
|
||||
message: format!("broadcast failed for agents: {}", errors.join(", ")),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match coord.broker.send(&Message {
|
||||
from: MANAGER_AGENT.to_owned(),
|
||||
to: to.clone(),
|
||||
body: body.clone(),
|
||||
}) {
|
||||
Ok(()) => ManagerResponse::Ok,
|
||||
Err(e) => ManagerResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
ManagerRequest::OperatorMsg { body } => match coord.broker.send(&Message {
|
||||
from: hive_sh4re::OPERATOR_RECIPIENT.to_owned(),
|
||||
to: MANAGER_AGENT.to_owned(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue