-
Notifications
You must be signed in to change notification settings - Fork 24
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
Global lazy #692
Comments
Not at the moment, though that's something we can try to add |
What is the use case? Why are you looking to apply this globally like that is a good thing to do? I'm coming from the perspective that ideally Lazy isn't used much (Eager is preferred). In the server-side K8s case, when we start a service and respond OK to readiness we really want the service to be "Fully honest" along the lines "Yes I have started, I have initialised everything I need and I am ready to receive production traffic". In the everything is lazy case, we are really susceptible to saying OK to readiness without having initialised much at all ... and failing when trying to handle production traffic - in my view this is not cool relative to the "fail fast" / "Don't say OK to readiness unless are all truely all ready to serve production traffic". Lazy was initially added for the JavaFX UI case, to delay initialisation of things that were relatively expensive and could be reasonably deferred to initialise lazily. What is the use case you are looking at? Why do you think global lazy is a good idea for that use case? |
Thanks for considering. The production case makes perfect sense. The use case is more for dev / testing. In this case faster startup / restarts would be preferred. Spring devtools for example does provide hot reload with custom classloader so not everything restarts. It does have its quirks though. At the moment I'm using inject and just restarting, which can take a while with lots of services and connections. Hoping to also create preview builds per PR and having everything lazy would speed things up. |
It sounds like the case of building a Web UI (probably with server side rendering) and hence restarting the server frequently.
We can't do this transparently without using a more advanced AOP approach [along the lines of a javaagent]. That is, on the side when a component is injected we are effectively look to inject a |
why not just add an annotation that changes the default generation behavior to make all beans lazy? |
Because it can't be done transparently. All the use sites need to change to |
What I understood by the issue was that it can be a hassle to manually add the lazy annotation everywhere when you desire your entire application to be lazy. Would not enhancing the annotation to work on a package/module level resolve that inconvenience? Edit: oh wait I see what you're talking about, I had forgotten that one needs to use providers for lazy |
Hi, are there configuration options for inject, e.g. to apply lazy globally? Spring had an option to globally mark everything as lazy.
Trying to port an application to use this, but seems tedious to maintain
@Lazy
everywhere. Thanks!The text was updated successfully, but these errors were encountered: