-
Notifications
You must be signed in to change notification settings - Fork 562
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
RulesEngine lifetime and thread-safety #580
Comments
@Makciek , it is recommended to use it as single instance to benefit from caching of compilation. Also, it is thread safe, so you can use same instance at same time |
Hello, I'm curious about the thread safety of the localParam. If we aim to record the result of rule evaluation and assign it to a local parameter, could it be overwritten by other rule evaluations with different inputs? For instance, let's say we construct a rule containing blacklist words. If the text contains any of these blacklist words, we wish to record the offensive word in the localParam and utilize it to generate the FailureMessage. |
@vanwx localParam is like a local variable in code, they do not share reference with any other rule or execution. So it should be completely thread safe |
Yeah thanks @abbasc52 . I did write some tests and it's been safe. Also I found some examples on this repo use the localParam to store result state so it's good. |
Hello
I can't find it in docs nor in wiki, what's the advised lifetime of the RulesEngine object? Should I create it every time I need it and it will cache the compiled evaluator itself or should I create just one instance and cache it? If so is it thread-safe and I can reuse the same instance at the same time?
The text was updated successfully, but these errors were encountered: