resilience4j / resilience4j

Resilience4j is a fault tolerance library designed for Java8 and functional programming
Apache License 2.0
9.73k stars 1.33k forks source link

Question or feature request: Compile time weaving #1641

Closed esimioni closed 2 years ago

esimioni commented 2 years ago

I'm aware of the Spring Boot integration, and as far as I could understand, it works with load time weaving. LTW is error prone (a missing or wrong configuration and your code will run as if resilience4j was not there), and painfully slow, since Spring Boot scans everything on the application classpath searching for annotations. In our case, just by having resilience4j on the classpath (thus triggering Spring Boot search for its annotations), increased the application boot time by ~30%.

We use compile time weaving for everything in our projects, from external to internal aspects, but I couldn't find a way to apply it to resilience4j aspects. I've tried the same recipe that works for Spring aspects, but the compiled class is not weaved.

Is it possible to do it or would it need some development on the lib to work?

lejtemxviw commented 2 years ago

Not that I would recomment this as the best solution - but IIRC, and if Spring Boot is using AOP for runtime weaving, you could add a file META_INF/aop.xml that restricts what packages it will scan for annotations to process. That might reduce that initial penalty you've seen?

RobWin commented 2 years ago

Hi,

duplicate of https://github.com/resilience4j/resilience4j/issues/391