Skip to content

SagaDagIterator could/should implement ExactSizeIterator #164

@smklein

Description

@smklein

Context: oxidecomputer/omicron#3895 (comment)

Current Implementation:

steno/src/dag.rs

Lines 387 to 405 in 77d8f20

impl<'a> Iterator for SagaDagIterator<'a> {
type Item = NodeEntry<'a>;
fn next(&mut self) -> Option<Self::Item> {
while let Some(node) = self.dag.get(self.index) {
let index = self.index;
self.index = NodeIndex::new(self.index.index() + 1);
match node {
InternalNode::Action { .. }
| InternalNode::Constant { .. }
| InternalNode::SubsagaEnd { .. } => {
return Some(NodeEntry { internal: node, index })
}
_ => (),
}
}
None
}
}

Advantages of doing this:

  • It would be easier to iterate over the nodes under saga idempotency tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions