GithubHelp home page GithubHelp logo

Comments (2)

Clayton7510 avatar Clayton7510 commented on May 18, 2024 1

By default a rule is set to RuleChainActionType.CONTINUE_ON_FAILURE. That means that the rule chain will continue (i.e. the next rule in the chain will be evaluated) if the rule's "when" condition evaluates to false or if there is an error evaluating the rule. The rule is then, in effect, skipped. However, the rule chain will break if and only if the RuleState is set to BREAK (e.g. if the stop() method is used in the RuleBuilder), the rule's condition evaluates to true and there is no error when evaluating the rule. And if RuleState was not set to BREAK, the "when" condition evaluated to true and the rule's action(s) completed successfully then the rule chain continues and the next rule is evaluated. This was the only behavior of rules in RuleBook prior to v0.8 and it is now the default behavior.

Alternatively, if a rule is set to RuleChainActionType.STOP_ON_FAILURE then if the rule's condition evaluates to false or if an error is thrown while RuleState is BREAK, the rule chain is broken. However, if the rule's "when" condition evaluates to true without error, the rule chain continues. It's basically a way to break the rule chain on a failed rule.

What you saw in the code where STOP_ON_FAILURE sets the rule to RuleState.NEXT is a way of ensuring that the rule chain continues with STOP_ON_FAILURE set when the rule is successful (it's "when" condition evaluates to true). It was done like that so that it could work with the existing rule chain logic in the CoRRuleBook.

Does that make sense? I, personally didn't really like having two different possible behaviors. However, more than one person asked for a feature to break the rule chain on a failed rule. So, STOP_ON_FAILURE was an easy way to allow that to happen.

from rulebook.

danielmustafa avatar danielmustafa commented on May 18, 2024 1

Thank you for the explanation

from rulebook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.