Watch
0
0
Fork
You've already forked hyperhive
0

the harness no longer publishes the agent's icon; the controller is its only writer

This commit is contained in:
iris 2026-11-16 23:07:18 +01:00 • committed by mara
commit fe4d68c13f

View file

@ -5,8 +5,8 @@
//! a write can arrive before it exists; that write and any other failed one are
//! retried with backoff until one is acked.
//!
//! Shared by the writers of an agent's own keys: [`crate::swarm_agent_icon`]
//! and [`crate::swarm_agent_commands`].
//! Shared by the writers of an agent's own keys, such as
//! [`crate::swarm_agent_commands`].
use std::time::Duration;
@ -20,17 +20,10 @@ const FIRST_RETRY: Duration = Duration::from_secs(5);
/// Longest wait between retries.
const MAX_RETRY: Duration = Duration::from_mins(5);
/// The KV header and value that mark an entry deleted. `kv::Store::get`
/// answers `None` for an entry carrying them.
const KV_OPERATION: &str = "KV-Operation";
const KV_OPERATION_DELETE: &str = "DEL";
/// What to write under a key.
pub enum Put<'a> {
/// These bytes as the key's value.
Set(&'a [u8]),
/// Delete the key.
Delete,
}
/// Why a write did not land.
@ -53,15 +46,8 @@ async fn put_once(
// server has announced its own.
swarm_queue_client::ensure_connected(client)
.map_err(|e| Failure::Retry(swarm_queue_client::chain(&e)))?;
let sent = match put {
Put::Set(bytes) => js.publish(subject.to_owned(), bytes.to_vec().into()).await,
Put::Delete => {
let mut headers = async_nats::HeaderMap::new();
headers.insert(KV_OPERATION, KV_OPERATION_DELETE);
js.publish_with_headers(subject.to_owned(), headers, Vec::new().into())
.await
}
};
let Put::Set(bytes) = put;
let sent = js.publish(subject.to_owned(), bytes.to_vec().into()).await;
let ack = sent.map_err(|e| match e.kind() {
PublishErrorKind::MaxPayloadExceeded => Failure::TooLarge(e),
_ => Failure::Retry(e.to_string()),