-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ArC: initial support for inactive synthetic beans #41810
Conversation
Just to be sure: the synthetic bean builder ( |
Hey @Ladicek , thanks for working on this. I'll try to integrate this ASAP, but in the meantime, a few comments:
Okay, but the requirement was to eagerly initialize only if the bean is active and injected into a user bean. From the issue:
I'll have to try, but I suspect without this additional condition, we'll have a few problems, like users discovering only at runtime that their datasource (which they inject and use) didn't start because of missing configuration. Relatedly, one of the main purposes of implementing this in Arc itself (as opposed to doing it by hand in extensions) was this:
I will let you know of my results when I've had a try. Thanks again. |
Yeah, so that's one of the things I didn't understand. How can you have an active but unconfigured datasource? If the datasource is unconfigured, it is inactive, like, by definition. No? I suppose this is an area where more work is required, but I don't really understand what that work is, so I left it for later.
Actually, also DONE. At least if I understand the requirement correctly. If there's an inactive bean, any attempt to create an instance of that bean (which will happen during startup if the synthetic bean is configured with
|
I think that's how we ended up defining this... though that's not the current definition. I have a hard time determining if there are cases where we actually want an unconfigured datasource to be considered active (e.g. to get specific errors). I'll I'll have to try. That being said... if we accept your definition, the requirement becomes this:
I.e.: since we're now skipping eager initialization for datasources that are inactive, we need to check that no other (user) bean is using these datasources, otherwise the user may start their app forgetting to set the JDBC URL, think everything is fine, and see the app fail on the first request (first time the datasource bean gets accessed). |
Ouch, yeah, good point. If the bean is not active, initialization on |
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InjectableBean.java
Outdated
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeanBuildItem.java
Outdated
Show resolved
Hide resolved
89f154f
to
626f1f9
Compare
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I this gave a first try here (very incomplete, but it's a start): #41929
I added comments below based on what I noticed.
Right now I'm kind of stuck because whenever there's a bean initialized on startup, and it's inactive, startup fails... even if the bean is not injected in a user bean. See my comment below.
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeanBuildItem.java
Outdated
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java
Outdated
Show resolved
Hide resolved
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InactiveBeanException.java
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java
Outdated
Show resolved
Hide resolved
626f1f9
to
fe0058a
Compare
Rebased on current |
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeansProcessor.java
Outdated
Show resolved
Hide resolved
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
fe0058a
to
980947b
Compare
980947b
to
0debb55
Compare
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/ActiveResult.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Ladicek ,
First, sorry for the delay. It's been hard to find time for "features and enhancements" in the past few weeks. But I finally managed to get back to it!
Second, my PR #41929 is in good shape now, and I managed to do everything I needed with your current PR. So, as far as I'm concerned, +1 to merge! I added a few comments, and there are a few unaddressed ones from previous reviews, but I'll let you decide if you want to address them now, later, or never :)
Thanks for all this!
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/InactiveBeanException.java
Show resolved
Hide resolved
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanGenerator.java
Outdated
Show resolved
Hide resolved
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeanBuildItem.java
Outdated
Show resolved
Hide resolved
Thanks @yrodiere, I'll take a look at the open comments and will do something about them. I should be able to mark this as ready for review in the coming days. |
0debb55
to
4bcd1c6
Compare
Done and marked as ready. Leaving out for the future:
|
Good point. I totally forgot about adding docs. Will do. |
034acdb
to
2789c1c
Compare
2789c1c
to
2eb9c33
Compare
Hi @yrodiere, in the conversation with @mkouba (see above), we slightly changed the logic in |
🙈 The PR is closed and the preview is expired. |
This comment has been minimized.
This comment has been minimized.
2eb9c33
to
bdd234e
Compare
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SyntheticBeanBuildItem.java
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for the heads-up. I don't think it will be a problem, and in fact it's something that I wanted initially, but that we had postponed as not being "MVP-worthy", so I'm glad to see it in :) See #41466:
Anyway, I rebased my PR, which is building there: https://github.com/yrodiere/quarkus/actions/runs/11210350803 |
bdd234e
to
30325f2
Compare
Status for workflow
|
Status for workflow
|
Tests passed 🎉 |
Fixes #41466