hive-sh4re: split manager-socket constants + HelperEvent into their own topic module
This commit is contained in:
parent
02bbff1e34
commit
138f6b6c10
24 changed files with 268 additions and 244 deletions
|
|
@ -14,7 +14,8 @@ use std::sync::Arc;
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use hive_core_agent_sock::{Request, Response};
|
||||
use hive_sh4re::{MANAGER_AGENT, Message};
|
||||
use hive_sh4re::Message;
|
||||
use hive_sh4re::manager::MANAGER_AGENT;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio::net::{UnixListener, UnixStream};
|
||||
use tokio::task::JoinHandle;
|
||||
|
|
@ -340,7 +341,7 @@ fn handle_wake(
|
|||
body: &str,
|
||||
) -> hive_core_agent_sock::Response {
|
||||
match coord.broker.send(&Message {
|
||||
from: hive_sh4re::trusted_sender(from),
|
||||
from: hive_sh4re::manager::trusted_sender(from),
|
||||
to: agent.to_owned(),
|
||||
body: body.to_owned(),
|
||||
in_reply_to: None,
|
||||
|
|
@ -483,7 +484,7 @@ fn handle_operator_msg(
|
|||
body: &str,
|
||||
) -> hive_core_agent_sock::Response {
|
||||
match coord.broker.send(&Message {
|
||||
from: hive_sh4re::trusted_sender(hive_sh4re::OPERATOR_RECIPIENT),
|
||||
from: hive_sh4re::manager::trusted_sender(hive_sh4re::manager::OPERATOR_RECIPIENT),
|
||||
to: agent.to_owned(),
|
||||
body: body.to_owned(),
|
||||
in_reply_to: None,
|
||||
|
|
@ -938,7 +939,7 @@ pub(crate) fn fan_out_send(
|
|||
continue;
|
||||
}
|
||||
if let Err(e) = coord.broker.send(&Message {
|
||||
from: hive_sh4re::trusted_sender(from),
|
||||
from: hive_sh4re::manager::trusted_sender(from),
|
||||
to: target.clone(),
|
||||
body: body.to_owned(),
|
||||
in_reply_to,
|
||||
|
|
@ -977,7 +978,7 @@ pub(crate) fn handle_send(
|
|||
// topology.json. Bypasses the allow-list check — structural fan-out
|
||||
// targets are never user-listed peers. No-op (returns Ok) for leaf
|
||||
// agents that have no children.
|
||||
if to == hive_sh4re::CHILDREN_RECIPIENT {
|
||||
if to == hive_sh4re::manager::CHILDREN_RECIPIENT {
|
||||
let children = crate::topology::children_of(agent);
|
||||
let errors = fan_out_send(coord, agent, body, in_reply_to, &children);
|
||||
return if errors.is_empty() {
|
||||
|
|
@ -1007,7 +1008,7 @@ pub(crate) fn handle_send(
|
|||
),
|
||||
};
|
||||
}
|
||||
if resolved != hive_sh4re::OPERATOR_RECIPIENT {
|
||||
if resolved != hive_sh4re::manager::OPERATOR_RECIPIENT {
|
||||
// A name that doesn't parse as an Ident can't be a local agent, so
|
||||
// it collapses into the same "unknown recipient" error as a valid
|
||||
// name with no state dir.
|
||||
|
|
@ -1023,7 +1024,7 @@ pub(crate) fn handle_send(
|
|||
}
|
||||
}
|
||||
match coord.broker.send(&Message {
|
||||
from: hive_sh4re::trusted_sender(agent),
|
||||
from: hive_sh4re::manager::trusted_sender(agent),
|
||||
to: resolved,
|
||||
body: body.to_owned(),
|
||||
in_reply_to,
|
||||
|
|
@ -1086,12 +1087,12 @@ pub fn spawn_question_watchdog(coord: &Arc<Coordinator>, id: i64, ttl_secs: u64)
|
|||
if let Ok((question, asker, target)) =
|
||||
coord
|
||||
.questions
|
||||
.answer(id, TTL_SENTINEL, hive_sh4re::OPERATOR_RECIPIENT)
|
||||
.answer(id, TTL_SENTINEL, hive_sh4re::manager::OPERATOR_RECIPIENT)
|
||||
{
|
||||
tracing::info!(%id, %asker, "question expired (ttl)");
|
||||
coord.notify_agent(
|
||||
&asker,
|
||||
&hive_sh4re::HelperEvent::QuestionAnswered {
|
||||
&hive_sh4re::manager::HelperEvent::QuestionAnswered {
|
||||
id,
|
||||
question,
|
||||
answer: TTL_SENTINEL.to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue