microsoft / RulesEngine

A Json based Rules Engine with extensive Dynamic expression support
https://microsoft.github.io/RulesEngine/
MIT License
3.47k stars 528 forks source link

Possibility to choose the execution of all actions or not #596

Open EricoSC opened 3 months ago

EricoSC commented 3 months ago

Hi!

I'm doing experiments with this engine, where I'm simulating some real cases in my work and studying possibilities where my current scenario is not able to perform.

Looking deeper into this project, all actions linked to the rules will be executed.

image

The scenario I'm simulating is: When I have an entity that are parameters of the rule, and I have several rules that there are actions to be executed, I want only the first success/failure match to be executed.

I know that in the library there is a method where I can execute the action in isolation. image

My idea is to use it for this purpose, where I can send the only first action decision to external APIs, but the engine is designed to execute all actions when registered in success or not

A quick fix would be to add a non-required boolean parameter in the ExecuteAllRulesAsync method that indicates that we don't want to execute the actions so no action will be performed after all the rules are executed, or add a property in the rule indicating that it is not to execute the given action, so we could have the choice that that rule can execute the action automatically without handling the ExecuteActionWorkflowAsync method for that rule.

asulwer commented 5 days ago

this project is no longer maintained but...my fork is. i can look into adding support for your question