the harness no longer publishes the agent's icon; the controller is its only writer
This commit is contained in:
parent
2e30163d5c
commit
fe4d68c13f
1 changed files with 15 additions and 170 deletions
|
|
@ -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()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue