-
Notifications
You must be signed in to change notification settings - Fork 15
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
Throw when times-to-try > 1 and actual is a value #116
Conversation
I made a choice here to warn when running the flow. Other options include:
Anybody prefer any of those options? If so, why? |
(when (and (> (:times-to-try ~params*) 1) | ||
(not (state/state? ~actual))) | ||
(log/warn (select-keys ~caller-meta [:line]) | ||
":times-to-try > 1 has no meaningful effect when 'actual' is a value.")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is obvious for those who are used to work with state-flow
but should we add, "'actual' should be a flow" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "actual should be a step or a flow when :times-to-try > 1"?
I don't see why someone would want to retry something that is always the same, so I think an exception makes sense here (on compiling flow) |
I agree. My concern is that this is a breaking change for tests that are unnecessarily using |
Yeah. All the tests that explicitly use times-to-try really want it to be retried I think. I don't expect many (or at all) people using |
I agree with @sovelten, an exception seems a better approach here. |
Macroexpansion-time exception it is. Please re-review @sovelten and @fernando-nubank |
e5f1b2b
to
b2531b4
Compare
b2531b4
to
014c300
Compare
|
||
(testing "with times-to-try > 1 and a value instead of a step" | ||
(testing "throws" | ||
(is (re-find #"actual must be a step or a flow when :times-to-try > 1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: custom exception catching because the top-level exception is CompilationError because we're throwing at macroexpansion time.
This turns out to be a breaking change for anybody upgrading from state-flow before 2.2.4 and using the old version of Options:
/cc @nubank/eng-prod-test @sovelten |
Users have reported failures when probing where it turned out that
match?
was given a value instead of a step to produce the value, e.g.This PR adds a warning when :times-to-try is > 1 and
actual
is a value instead of a step.