oxidecomputer / steno

distributed sagas
Apache License 2.0
117 stars 10 forks source link

`SagaDagIterator` could/should implement `ExactSizeIterator` #164

Open smklein opened 1 year ago

smklein commented 1 year ago

Context: https://github.com/oxidecomputer/omicron/pull/3895#discussion_r1297738612

Current Implementation: https://github.com/oxidecomputer/steno/blob/77d8f2003cb26578eaf80dd2982eda64e2abb80d/src/dag.rs#L387-L405

Advantages of doing this:

smklein commented 1 year ago

After taking a brief look at this, I don't think this is trivial -- though I'd love to reach into SagaDag.graph and just query for the node_count (https://docs.rs/petgraph/latest/petgraph/graph/struct.Graph.html#method.node_count) , I don't think it's so simple.

Therefore, we would need to track the count of all subsagas to be able to infer the named node count (graph.node_count() - (2 + subsaga_count)). This would introduce additional accounting that would need to exist test-only cases.