refactor: unify AgentServer + ManagerServer into HiveServer {socket, flavor}
This commit is contained in:
parent
1698372572
commit
c634dab2a6
3 changed files with 379 additions and 726 deletions
|
|
@ -345,6 +345,29 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
Err(message) => AgentResponse::Err { message },
|
||||
}
|
||||
}
|
||||
AgentRequest::Start { name } => {
|
||||
if !crate::topology::children_of(agent)
|
||||
.iter()
|
||||
.any(|c| c == name)
|
||||
{
|
||||
return AgentResponse::Err {
|
||||
message: format!(
|
||||
"agent `{agent}` cannot start `{name}`: \
|
||||
not a direct child in the topology tree"
|
||||
),
|
||||
};
|
||||
}
|
||||
tracing::info!(%agent, %name, "agent: start child");
|
||||
match crate::lifecycle::start(name).await {
|
||||
Ok(()) => {
|
||||
coord.kick_agent(name, "container started");
|
||||
AgentResponse::Ok
|
||||
}
|
||||
Err(e) => AgentResponse::Err {
|
||||
message: format!("{e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
AgentRequest::Restart { name } => {
|
||||
// Topology check: the caller must be the direct parent of the
|
||||
// target. This is the only authorisation criterion — no
|
||||
|
|
|
|||
Loading…
Reference in a new issue