notify router: deliveries log, dry-run hit counts, api and page
This commit is contained in:
parent
6dd9d0086e
commit
ed1fd053e7
1 changed files with 1848 additions and 40 deletions
|
|
@ -43,10 +43,10 @@ pub struct ReviewRequest {
|
|||
pub reviewer: String,
|
||||
}
|
||||
|
||||
/// Walk `flow` for one event of type `event_type`, calling `leaf` on each
|
||||
/// `todo` and `request_reviewer` node the event reaches. Assumes
|
||||
/// [`Flow::validate`] passed.
|
||||
fn walk<'f>(flow: &'f Flow, event_type: &str, fields: &Fields, mut leaf: impl FnMut(&'f Node)) {
|
||||
/// Walk `flow` for one event of type `event_type`, calling `visit` on each node
|
||||
/// the event reaches: the `source`, each `match` it passes, and the `todo` and
|
||||
/// `request_reviewer` nodes below. Assumes [`Flow::validate`] passed.
|
||||
fn walk<'f>(flow: &'f Flow, event_type: &str, fields: &Fields, mut visit: impl FnMut(&'f Node)) {
|
||||
let Some(root) = flow
|
||||
.nodes
|
||||
.iter()
|
||||
|
|
@ -58,17 +58,30 @@ fn walk<'f>(flow: &'f Flow, event_type: &str, fields: &Fields, mut leaf: impl Fn
|
|||
while let Some(id) = stack.pop() {
|
||||
let Some(node) = flow.node(id) else { continue };
|
||||
match &node.kind {
|
||||
NodeKind::Source { .. } => stack.extend(flow.children(id).into_iter().rev()),
|
||||
NodeKind::Source { .. } => {
|
||||
visit(node);
|
||||
stack.extend(flow.children(id).into_iter().rev());
|
||||
}
|
||||
NodeKind::Match { when } => {
|
||||
if when.iter().all(|c| holds(c, fields)) {
|
||||
visit(node);
|
||||
stack.extend(flow.children(id).into_iter().rev());
|
||||
}
|
||||
}
|
||||
NodeKind::Todo(_) | NodeKind::RequestReviewer { .. } => leaf(node),
|
||||
NodeKind::Todo(_) | NodeKind::RequestReviewer { .. } => visit(node),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the nodes of `flow` that one event of type `event_type` reaches,
|
||||
/// a `match` node counting only when it passes. Emits nothing: this is the
|
||||
/// dry run's view of the walk that [`evaluate`] and [`requests`] make.
|
||||
pub fn reached<'f>(flow: &'f Flow, event_type: &str, fields: &Fields) -> Vec<&'f str> {
|
||||
let mut ids = Vec::new();
|
||||
walk(flow, event_type, fields, |node| ids.push(node.id.as_str()));
|
||||
ids
|
||||
}
|
||||
|
||||
/// Walk `flow` for one event of type `event_type` and return the todo ops it
|
||||
/// emits. Assumes [`Flow::validate`] passed.
|
||||
pub fn evaluate(flow: &Flow, event_type: &str, fields: &Fields) -> Vec<Action> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue