Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/swarm-queue-client/src/agent_status.rs

22 lines
802 B
Rust

//! The connection side of the per-agent status KV bucket: opening it for
//! writing. The bucket's name, keys and stored type are
//! `swarm_wire::agent_status`.
/// Open the agent-status bucket, creating it if nothing has yet.
///
/// `history: 1`, same rationale as [`crate::status::open_or_create`]: a
/// consumer wants the last thing each agent said, not a log of everything
/// it has ever said.
#[cfg(feature = "kv")]
pub async fn open_or_create(
client: &async_nats::Client,
) -> Result<async_nats::jetstream::kv::Store, crate::Error> {
let js = async_nats::jetstream::new(client.clone());
crate::kv::open_or_create(
&js,
swarm_wire::agent_status::BUCKET,
"agent-status",
"Last status snapshot offered by each agent".to_owned(),
)
.await
}