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

Implemented anomaly and exception handle maps #40

Merged
merged 4 commits into from
Apr 12, 2019

Conversation

ElChache
Copy link
Collaborator

Anomaly handlers is map of functions indexed by step name that get called with a map {:ctx <ctx> :anomaly <anomaly>} when the step returns an anomaly.

Exception handlers is a map of functions indexed by step name that get called with a map {:ctx <ctx> :exception <exception>} when the step triggers an exception.

Both are given in the configuration map of fonda under :anomaly-handlers and :exception-handlers, and both are optional.

@arichiardi
Copy link
Owner

Awesome will check that soon

Copy link
Owner

@arichiardi arichiardi left a comment

Choose a reason for hiding this comment

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

I have only one feature request on this feature 😀

Should this handler map have always keyword keys?

Even if the name a string we can convert it to keyword. It is more idiomatic and we can also directly use that keyword that resolves to a function without problems.

What do you think?

CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/fonda/core/specs.cljc Show resolved Hide resolved
@ElChache
Copy link
Collaborator Author

Yes I totally agree to that, strings as keys in the maps didn't feel right. I also think the step names should be allowed to be keywords as well, either strings or keywords. I always write them as keywords and them get an error. That's a different issue tho. I'll implement that tomorrow, now I'm watching Barcelona Man U 😄 ⚽

@arichiardi
Copy link
Owner

I thought we already allow name to be a string or keyword but I will double check as well

@ElChache
Copy link
Collaborator Author

Yes right now steps must be strings:

(s/def ::name (s/nilable string?))

I think the proper approach would be to always convert the steps names and handler map keys into keywords. Then the user can use strings or keywords indifferently. What do you think?

@arichiardi
Copy link
Owner

Totally we should do that

ElChache and others added 4 commits April 12, 2019 11:13
The fonda.core and fonda.execute have a different specification of the step name
key, so we duplicate the step specs, waiting for spec2 to save the boat.
@arichiardi arichiardi merged commit 74ca62f into master Apr 12, 2019
@arichiardi arichiardi deleted the exception-anomaly-handlers branch April 12, 2019 18:15
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.

None yet

2 participants