feat(#589): swarm peers option + HYPERHIVE_PEERS env wire v0
nix: services.hyperhive.peers attrset-of-submodules option; serialises
to HYPERHIVE_PEERS JSON ([{label,domain}]); forwarded to containers via
FORWARDED_VARS. dashboard.rs: peer_hives: Vec<PeerHiveView> in
StateSnapshot, derived as {name:label, url:"http://domain/"}.
identity.rs: PeerHive struct + peers() accessor for agent-side use.
This commit is contained in:
parent
cce85a6c1b
commit
348fb3792a
4 changed files with 121 additions and 0 deletions
|
|
@ -48,6 +48,25 @@ pub fn swarm_name() -> Option<String> {
|
|||
.filter(|s| !s.is_empty())
|
||||
}
|
||||
|
||||
/// One peer hive in the same swarm. Parsed from `HYPERHIVE_PEERS`.
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
pub struct PeerHive {
|
||||
pub label: String,
|
||||
pub domain: String,
|
||||
}
|
||||
|
||||
/// Peer hives in the same swarm, parsed from `HYPERHIVE_PEERS` env var
|
||||
/// (JSON array of `{label,domain}` objects, emitted by the c0re NixOS
|
||||
/// module from `services.hyperhive.peers`). Returns empty vec on
|
||||
/// single-hive deploys (env var absent).
|
||||
#[must_use]
|
||||
pub fn peers() -> Vec<PeerHive> {
|
||||
env::var("HYPERHIVE_PEERS")
|
||||
.ok()
|
||||
.and_then(|s| serde_json::from_str(&s).ok())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Hive-qualified agent identity. When the hive domain is configured, returns
|
||||
/// `${label}@${domain}` (e.g. `iris@darkest.space`); when not, returns just
|
||||
/// the short label so callers can render a single string regardless of
|
||||
|
|
|
|||
Loading…
Reference in a new issue