Skip to content

Conversation

@julio4
Copy link
Collaborator

@julio4 julio4 commented Nov 10, 2025

Stacked on #58

This PR introduce a first atomic combinator step where all steps must succeed (ControlFlow::Ok) in order to mutate payload.

It uses the CombinatorStep with a new AtomicMode, and a macro that allows to quickly define atomic combinator steps like:

atomic!(StepA, StepB, StepC);

Comment on lines +22 to +23
ControlFlow::Break(_) => return ControlFlow::Break(initial),
ControlFlow::Fail(error) => return ControlFlow::Fail(error),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intuition is that those two variants should return ControlFlow::Ok(initial). Though this is a matter of the intention behind this step.

Comment on lines +77 to +78
let result = OneStep::<P>::new(composite).run().await?;
assert!(matches!(result, ControlFlow::Fail(_)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should ControlFlow::Fail in Atomic when one of its sub-steps fail or should we return ControlFlow::Ok(_) of the initial payload?

My thoughts are that if Atomic propagates ControlFlow::Fail and ControlFlow::Break then it is no different than pipeline.step(S1).step(S2).step(S3).

As a user of this API I would imagine Atomic enabling behavior that is not available out of the box in pipeline syntax and behave somehow similar to CAS semantics in atomic operations:

  • Either all sub-steps succeed with ControlFlow::Ok(_), in which case the resulting payload would be equivalent to fold.
  • Or if any of the sub-steps returns non-ControlFlow::Ok(_), then the original input payload is returned as ControlFlow::Ok(_).
  • I think that people using atomic!() already expect some of the steps to fail but they don't necessarily want those steps failures to propagate to pipeline failures.

What are your thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this makes sense, we should go with what you described. I didn't think through the whole logic of Atomic too much at first

@julio4 julio4 changed the title feat: atomic composit step feat: atomic combinator step Nov 11, 2025
@julio4
Copy link
Collaborator Author

julio4 commented Nov 11, 2025

I will close this and move it directly to #58

@julio4 julio4 closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants