Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework step conditional execution #53

Merged
merged 1 commit into from
Aug 7, 2022
Merged

Rework step conditional execution #53

merged 1 commit into from
Aug 7, 2022

Conversation

ccremer
Copy link
Owner

@ccremer ccremer commented Aug 7, 2022

Summary

Predicates wrapping steps doesn't quite feel right. For instance, previous If implementation created an additional step that had the same name as for the step that would be executed if it evaluated to true.

This PR makes conditional and predicates first-class citizen in the pipeline. Step has now a new field Condition Predicate[T]. If set, the pipeline will evaluate the condition prior to executing a Step's Action().

Change summary:

  • pipeline.If is removed. use NewStep(...).When(predicate) instead.
  • pipeline.IfOrElse is removed, use NewStep(...).When(pipeline.Not(predicate) instead.
  • New method Pipeline.When(predicate, name, action
  • New func NewStepIf(predicate, name, action)
  • New method Step.When(predicate)
  • Pipeline.WithNestedSteps has now Predicate[T] in the signature. It accepts nil as well.

Checklist

  • Categorize the PR by setting a good title and adding one of the labels:
    fix, enhancement, documentation, change, breaking, dependency
    as they show up in the changelog
  • Update documentation.
  • Update tests.
  • Link this PR to related issues.

@ccremer ccremer merged commit 23db1a0 into master Aug 7, 2022
@ccremer ccremer deleted the conditional-steps branch August 7, 2022 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant