Open willks opened 4 years ago
Yes, it does. This is done for thread safety. Although, perhaps there is a more elegant way to solve the problem.
I'm looking into switching this to a single scan. But the instantiation of the POJOs that are found in the scan will still take place on every run and there is a little reflection involved there since it transforms a POJO class representation into a Rule via an adapter.
There is an update in 0.12-SNAPSHOT that has a fix for this.
@Clayton7510 is there a way to turn off scan logging?
Sorry I didn't post this earlier. I worked around it before the 0.12-SNAPSHOT was posted. This is my code in Kotlin for setting up my rules. They have to be added in order of execution:
val pojoRules = listOf<Class<*>>(
EmptyPayloadRule::class.java,
ValidJsonRule::class.java,
TemperatureDeviceRule::class.java,
UnknownRule::class.java)
return RuleBookRunner4PojoClasses(pojoRules) as RuleBook<MyReturnEntityType>
This will avoid full scans, but the onus is on setting up order properly. Everything worked well. We're running these rules potentially hundreds/thousands of times per second through Kotlin Coroutines. It's held up well.
As a side note - this framework has been awesome for us. It allowed us to remove business rules into small, distinct, clear rules that are easy to update. The rest of our code is just calling out to these rules. I have smashed it with hundreds of threads simulating thousands of concurrent users. Didn't skip a beat!
One of my favourite projects on Github by far. Good work has been done here, much appreciated.
Thanks
@Clayton7510 With all that said, I found a work-around. I think we can close this issue out from my perspective.
Possible dupe of #155
Hi, Just a small question - but does every invocation of "SpringAwareRuleBookRunner" result in a full package scan? These are the logs I am seeing:
Just a question.
Thanks for a nice framework for rules