swarm-wire: take notices's wire types, fmt the moved imports
This commit is contained in:
parent
e111807f59
commit
fc72bea151
12 changed files with 72 additions and 86 deletions
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use swarm_wire::agent_limits::AgentCaps;
|
||||
use swarm_wire::agent_inference::AgentInference;
|
||||
use swarm_wire::agent_limits::AgentCaps;
|
||||
|
||||
/// The KV bucket archetype sources are published into, keyed by source name.
|
||||
pub const BUCKET: &str = "agent-archetypes";
|
||||
|
|
|
|||
|
|
@ -469,9 +469,9 @@ pub struct AgentInput {
|
|||
pub body: String,
|
||||
}
|
||||
|
||||
/// The hive-notices stream, shared by the hive that publishes and
|
||||
/// whatever eventually consumes it. Behind the `notices` feature, same
|
||||
/// reason `status` is behind `kv` — see the module doc.
|
||||
/// Opening the hive-notices stream. The name and subject are
|
||||
/// `swarm_wire::notices`. Behind the `notices` feature, same reason `status`
|
||||
/// is behind `kv`.
|
||||
#[cfg(feature = "notices")]
|
||||
pub mod notices;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,54 +1,12 @@
|
|||
//! The hive-notices stream: its name, subject shape, and how a hive
|
||||
//! opens it to publish.
|
||||
//! Opening the hive-notices stream a hive publishes lifecycle notices into. The
|
||||
//! stream name, subject shape and why it is a stream rather than a bucket are in
|
||||
//! `swarm_wire::notices`.
|
||||
//!
|
||||
//! Same reason [`crate::status`] exists rather than a bare `const` on
|
||||
//! whichever side happens to need one first: a hive that publishes and a
|
||||
//! swarm-level reader that eventually consumes live in different crates,
|
||||
//! and a literal name repeated across both is an agreement nothing
|
||||
//! checks.
|
||||
//!
|
||||
//! **This is a stream, not a bucket, and that is a real design choice —
|
||||
//! not the same shape as [`crate::status`] wearing a different name.**
|
||||
//! [`crate::status`]'s hive-status snapshot has a current value: a
|
||||
//! reconnecting reader can always ask "what does this hive say *now*"
|
||||
//! and get the true answer, so a KV bucket (last value per key) is the
|
||||
//! right shape. A lifecycle notice ("container crashed at 04:12") has no
|
||||
//! such steady state — miss the message and there is nothing left to
|
||||
//! read later that would tell you it happened. That needs durable
|
||||
//! delivery (a JetStream stream a consumer acks against), which is what
|
||||
//! this module opens instead.
|
||||
//!
|
||||
//! Feature-gated (`notices`) for the same reason [`crate::status`] is
|
||||
//! gated behind `kv`: the crate's other consumers (the auth-callout
|
||||
//! responder, a hive that only publishes status) should not compile
|
||||
//! Feature-gated (`notices`) so the crate's other consumers do not compile
|
||||
//! against a stream shape they never touch.
|
||||
|
||||
use crate::Error;
|
||||
|
||||
/// The stream a hive publishes lifecycle notices into.
|
||||
///
|
||||
/// A constant and not an option, matching [`crate::status::BUCKET`]:
|
||||
/// reader and writer must name the same stream, and letting either side
|
||||
/// pick its own name is how two deployments end up disagreeing about
|
||||
/// which stream a notice actually landed in.
|
||||
pub const STREAM: &str = "hive-notices";
|
||||
|
||||
/// Build the subject a given hive's notices publish to.
|
||||
///
|
||||
/// Every hive's notices land under `STREAM`, one subject per hive:
|
||||
/// `hive-notices.<hiveName>`.
|
||||
///
|
||||
/// Not one subject per notice *kind* — a consumer that wants a specific
|
||||
/// hive's notices subscribes to `subject(hive)`; one that wants the whole
|
||||
/// swarm's subscribes to `{STREAM}.>`. The kind travels inside the message
|
||||
/// payload instead, so adding a new notice kind is never a subject-design
|
||||
/// change. Deliberately reuses `STREAM` rather than a second `PREFIX`
|
||||
/// constant with the same value — one name for one fact, same reasoning
|
||||
/// the module doc above gives for a shared `const` over a repeated literal.
|
||||
#[must_use]
|
||||
pub fn subject(hive: &str) -> String {
|
||||
format!("{STREAM}.{hive}")
|
||||
}
|
||||
use swarm_wire::notices::STREAM;
|
||||
|
||||
/// Open the notices stream, creating it if nothing has yet.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue