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

move match? exception to flow execution time #125

Merged
merged 3 commits into from
May 19, 2020

Conversation

dchelimsky
Copy link
Contributor

@dchelimsky dchelimsky commented May 18, 2020

Before this PR match? would raise an exception at macroexpansion time if it was called in a syntactically correct by semantically incorrect way. With this PR, the update happens at flow execution time instead.

Additionally, in order to reduce upgrade friction, that exception is not thrown at all when calling the deprecated state-flow.cljtest/match? fn.

@dchelimsky dchelimsky force-pushed the dc/move-match-warning-to-macro-run-time branch from 7b80eb0 to b9dc683 Compare May 18, 2020 21:43
@dchelimsky dchelimsky changed the title move match warning to macro runtime move match? exception to flow execution time May 18, 2020
@dchelimsky dchelimsky marked this pull request as ready for review May 18, 2020 22:27
@@ -101,11 +101,12 @@
(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"
(.. (try
(eval `(mc/match? 3 (+ 30 7) {:times-to-try 2}))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eval here was a hint that we were doing it wrong.

Copy link
Contributor

@fernando-nubank fernando-nubank left a comment

Choose a reason for hiding this comment

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

🙈

@@ -10,7 +10,8 @@
(let [params* (merge {:times-to-try probe/default-times-to-try
:sleep-time probe/default-sleep-time
:caller-meta (meta &form)
:description match-desc}
:description match-desc
:called-from-deprecated-match? true}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used to tell the non-deprecated version of match? not to throw the times-to-throw exception so that when people upgrade from state-flow < 2.2.4, they don't start seeing exceptions right away.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rationale here is that the old default for times-to-try is 5, so the old match? was raising exceptions in a lot of cases by default.

@dchelimsky dchelimsky merged commit 5919a16 into master May 19, 2020
@dchelimsky dchelimsky deleted the dc/move-match-warning-to-macro-run-time branch May 19, 2020 18:30
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