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
Support of async rules. Again :) #202
Comments
I decided not doing it not because it's hard or easy. I agree it is straightforward, but, running rules asynchronously makes assumptions about how the engine is used. For example, it assumes the rules either don't use the IContext, or synchronize their access to it. It also assumes that the app hosting the engine wants to use the thread pool for rules action execution, etc., etc. |
And I'm looking forward to and would greatly appreciate collaboration on this project! |
Is there a way to do forward chaining asynchronously? |
@ansongoldade no, forward chaining cannot be asynchronous |
I'm just finding this project (interesting stuff!) and simply changing all the methods (e.g. Rule methods and those that invoke them) to async wouldn't be feasible? It's not about running code in true parallel but chaining async from possible IO calls through the Rules engine. You shoudn't have to change much other than adding await commands :) I might want to do things like retrieve and save data from a DB inside a rule. Just thinking how it would play out. |
Having played around further and trying to discover the best practices, maybe having IO type logic is considered an anti-pattern with this library? I’ve written some of my logic without IO in the rules but that requires gathering a lot of context upfront. I plan on attempting to make a PR for async usage. Still learning this library. Thanks again for it! |
Finally started looking at it. Quickly ran into Expression issues which I know next to nothing about expression trees. In my own usage, I've generally solved issues by first gathering all context, use a rules session, then inspect the results instead of trying to use EFCore or something inside the rules. Maybe this is the intended best practice? Avoid IO altogether in a rule? |
@adamhathcock yes, that's exactly my thinking - avoid IO inside the rules actions. |
The rules in my system mostly use IO. Having async helps me a lot, do you have a plan to add it? If not, can you guide me how to add this feature to the source? |
@snikolayev I've found a closed #84 issue labeled "wontfix". I've tried to implement the FireAsync() as you described and it was quite straightforward. BTW I haven't replaced Fire() with FireAsync() but implemented it in parallel.
So the question is why did you close this issue? Were there any hidden issues which I haven't faced yet, or it was just a decision to put it aside for a while?
Currently, we're investigating your project and potentially can collaborate :)
The text was updated successfully, but these errors were encountered: