archetype flows on the board list the agents the router sends to, and the docs say a switch-off key outlives its flow
This commit is contained in:
parent
68c24643f6
commit
13ff33ead0
1 changed files with 66 additions and 30 deletions
|
|
@ -192,7 +192,12 @@ pub(crate) async fn get_flows(
|
|||
/// logged and leaves the list empty: the document is still served.
|
||||
async fn archetype_flows(client: &async_nats::Client) -> Vec<ArchetypeFlowView> {
|
||||
let found = async {
|
||||
let refs = crate::agent_archetype::all(client).await?;
|
||||
// The router's members: the archetype keys of the agents in the swarm.
|
||||
let roster = swarm_queue_client::agent_status::roster(client)
|
||||
.await
|
||||
.map_err(|e| anyhow::anyhow!("listing the agents: {e}"))?;
|
||||
let mut refs = crate::agent_archetype::all(client).await?;
|
||||
refs.retain(|agent, _| roster.contains(agent));
|
||||
let mut records = BTreeMap::new();
|
||||
if let Some(store) = archetypes::open(client).await? {
|
||||
let sources: BTreeSet<&str> = refs.values().map(|r| r.source.as_str()).collect();
|
||||
|
|
@ -592,6 +597,8 @@ mod tests {
|
|||
("alice", "triage"),
|
||||
("bob", "triage"),
|
||||
("carol", "reviewer"),
|
||||
// In the bucket but not in the swarm: the router sends it nothing.
|
||||
("dave", "triage"),
|
||||
] {
|
||||
let choice = ArchetypeRef {
|
||||
source: BUILTIN_SOURCE.to_owned(),
|
||||
|
|
@ -603,6 +610,16 @@ mod tests {
|
|||
.expect("put the choice");
|
||||
}
|
||||
|
||||
let status = swarm_queue_client::agent_status::open_or_create(&client)
|
||||
.await
|
||||
.expect("status");
|
||||
for agent in ["alice", "bob", "carol"] {
|
||||
status
|
||||
.put(format!("hive.{agent}"), "{}".into())
|
||||
.await
|
||||
.expect("put the status");
|
||||
}
|
||||
|
||||
let Json(view) = get_flows(State(state.clone())).await.expect("get");
|
||||
assert_eq!(view.archetype_flows.len(), 1, "{:?}", view.archetype_flows);
|
||||
let listed = &view.archetype_flows[0];
|
||||
|
|
|
|||
Loading…
Reference in a new issue