-
Notifications
You must be signed in to change notification settings - Fork 1
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
WIP - Add previous result in step functions, mocked functions #43
base: master
Are you sure you want to change the base?
Conversation
988d5bf
to
fc859cc
Compare
src/fonda/execute.cljs
Outdated
inject (inject ctx)) | ||
assoc-result-fn (cond | ||
(let [ | ||
;; First step only gets the ctx, next ones receive last-result,ctx |
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.
Does this comment still apply?
:path [:github-things]}] | ||
|
||
;; on-exception | ||
(fn [exception] | ||
(fn [ctx exception] |
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.
I am going through all the breaking changes, this seems one.
Do we want to keep it? Is the context useful in case of exceptions? I remember back in the days we never needed it that's why it was not included in the signature.
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.
I like this signature more than anything because is consistent with all the callback functions signatures - the steps callbacks, and also the on-success callback, all have the same signature.
I also found very useful to be able to print the context when an exception happens.
And I can see it used when trying to recover from an error, maybe to repeat the flow from a certain step
(handle-exception exception)) | ||
|
||
;; on-success | ||
(fn [ctx] | ||
(handle-success (:github-things ctx)))) | ||
(fn [ctx last-step-res] |
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.
This is another but we discussed it already and it seemed useful.
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.
yes. Not breaking in Clojurescript, but would be breaking in Clojure
- [Optional] **on-anomaly** Function called in case of anomaly with the anomaly data itself. | ||
- **on-exception** Function with the signature `(fn [ctx exception])` called with the context and an exception when any of the steps throws one. | ||
- **on-success** Function with the signature `(fn [ctx last-step-result])` called with the context if all steps succeed, and the last step result. | ||
- [Optional] **on-anomaly** Function with the signature `(fn [ctx anomaly])` called in case of anomaly with the context and the anomaly data itself. |
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.
Ok I see we added the context also to this one. Sorry don't want to be a pain but just want to understand if really necessary 😄
cc9d4a8
to
d0c6e41
Compare
1a87d13
to
8d71131
Compare
- Tests fixed accordingly
af6724a
to
54df2b1
Compare
It can now be executed with yarn shadow-cljs compile simple-example and node dist/simple-example.js.
A couple of changes here. First of all the name specs in execute and core are now the same and both allow keyword and string for :name keys. Secondly, we refactor the specs so that including fonda.core.specs actually adds everything to the registry. Finally we fix the tests and issues that were detected with the change.
edc837c
to
f6afbf4
Compare
In a nutshell, the main new features are:
on-success
,on-error
,on-start
,on-complete
for status reporting.:is-anomaly-error?
attribute in the steps. The value is a function that would be called if the step returns an anomaly. If this function returns false, then the flow continues. This allows to break the circuit only with some anomalies.