an archetype carries its own notification-router flows for its agents
ArchetypeMeta gets flows, checked when the controller stores the record: every todo must go to the new members recipient, which the router expands to the agents of the archetype. The operator's flows document refuses members. The router reads the archetype records and each roster agent's archetype key, and its NATS grant gains read on both buckets.
This commit is contained in:
parent
ca339b7ba3
commit
1efbb72fdd
1 changed files with 883 additions and 29 deletions
|
|
@ -6,6 +6,7 @@
|
|||
//! recipient agent's subject of `ROUTER_TODOS` (`swarm_wire::router_todo`).
|
||||
//! Each agent's harness applies them to its own todo list. The flows are the
|
||||
//! built-in ones, changed by the `notify-flows` document ([`stored`]).
|
||||
//! The archetypes add flows of their own for their agents ([`archetype_flows`]).
|
||||
//!
|
||||
//! A `request_reviewer` node is a request to swarm-controller, which holds the
|
||||
//! forge token (`swarm_wire::router_sink`). It is sent once, after the event's
|
||||
|
|
@ -43,6 +44,7 @@ use swarm_wire::router_sink::{self, Outcome, RequestReviewer};
|
|||
use swarm_wire::{forge_events, notify_router, router_todo};
|
||||
|
||||
mod api;
|
||||
mod archetype_flows;
|
||||
mod dry_run;
|
||||
mod event;
|
||||
mod flow;
|
||||
|
|
@ -129,6 +131,7 @@ struct Router {
|
|||
events: jetstream::consumer::Consumer<pull::Config>,
|
||||
state: kv::Store,
|
||||
flows: stored::Flows,
|
||||
archetype_flows: archetype_flows::ArchetypeFlows,
|
||||
roster: Option<(Instant, BTreeSet<String>)>,
|
||||
metrics: metrics::Metrics,
|
||||
}
|
||||
|
|
@ -175,6 +178,7 @@ impl Router {
|
|||
events,
|
||||
state,
|
||||
flows: stored::Flows::builtins(),
|
||||
archetype_flows: archetype_flows::ArchetypeFlows::default(),
|
||||
roster: None,
|
||||
metrics: metrics::Metrics::from_env(),
|
||||
})
|
||||
|
|
@ -234,9 +238,15 @@ impl Router {
|
|||
};
|
||||
self.flows.refresh(&self.js).await;
|
||||
let roster = self.roster().await.map_err(Skip::Retry)?;
|
||||
let routed = route::route(&event_type, &delivery, &snapshot, &self.flows.active, |a| {
|
||||
roster.contains(a)
|
||||
});
|
||||
self.archetype_flows.refresh(&self.nats, &roster).await;
|
||||
let routed = route::route(
|
||||
&event_type,
|
||||
&delivery,
|
||||
&snapshot,
|
||||
&self.flows.active,
|
||||
&self.archetype_flows.active,
|
||||
|a| roster.contains(a),
|
||||
);
|
||||
let flows: BTreeSet<&str> = routed
|
||||
.actions
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Reference in a new issue