-
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
Export Neo4j driver as dedicated BuildItem. #11115
Export Neo4j driver as dedicated BuildItem. #11115
Conversation
Neo4jConfiguration configuration, | ||
ShutdownContextBuildItem shutdownContext) { | ||
|
||
recorder.configureNeo4jProducer(beanContainerBuildItem.getValue(), configuration, shutdownContext); | ||
Driver driver = recorder.initializeDriver(configuration, shutdownContext); |
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.
I don't think that will work, you need to use a RuntimeValue<Driver>
. We have plenty of examples if you look for RuntimeValue
in the code.
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.
Yes, this is absolutely correct. It might work even without it, but there is no point in risking it and not using RuntimeValue
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.
Just to clarify why this worked without RuntimeValue
: It worked because Driver
is an interface and as such the bytecode recorder knew to just create a proxy for it.
If however the class was not an interface, the whole endeavor would have failed 😉
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 for getting back with this info. Might come in handy some time to know this!
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.
You are welcome!
What exactly do you think won’t work?
I can access that driver instance during build (runtime init of course) as well as in the application via `@Inject` as before.
… Am 31.07.2020 um 17:22 schrieb Guillaume Smet ***@***.***>:
@gsmet commented on this pull request.
In extensions/neo4j/deployment/src/main/java/io/quarkus/neo4j/deployment/Neo4jDriverProcessor.java <#11115 (comment)>:
> Neo4jConfiguration configuration,
ShutdownContextBuildItem shutdownContext) {
- recorder.configureNeo4jProducer(beanContainerBuildItem.getValue(), configuration, shutdownContext);
+ Driver driver = recorder.initializeDriver(configuration, shutdownContext);
I don't think that will work, you need to use a RuntimeValue<Driver>. We have plenty of examples if you look for RuntimeValue in the code.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#11115 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAEAQL54IIDPLWZQ4BLJQODR6LOSBANCNFSM4PPVPOQQ>.
|
Maybe I misunderstood something but I thought you had to wrap the elements you returned from the recorder in a @geoand am I incorrect? |
It does work, actually (both JVM and native), but I’m gonna of course fix that.
Thanks for the insight!
… Am 31.07.2020 um 17:58 schrieb Georgios Andrianakis ***@***.***>:
@geoand commented on this pull request.
In extensions/neo4j/deployment/src/main/java/io/quarkus/neo4j/deployment/Neo4jDriverProcessor.java <#11115 (comment)>:
> Neo4jConfiguration configuration,
ShutdownContextBuildItem shutdownContext) {
- recorder.configureNeo4jProducer(beanContainerBuildItem.getValue(), configuration, shutdownContext);
+ Driver driver = recorder.initializeDriver(configuration, shutdownContext);
Yes, this is absolutely correct. It might work even without it, but there is no point in risking it and not using RuntimeValue
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#11115 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAEAQL7MNLMADIN2GVQY4LLR6LS2ZANCNFSM4PPVPOQQ>.
|
I updated the PR. Thanks again for your explanation. While working on this (and also on the client using it) I have to say, your exception messages are great and really helpful getting those things right! 👍 |
Looks great, thanks! Can you please squash the commits? |
This change allows other extensions to retrieve the driver during their deployment process and use it as dependency. The driver is wrapped as RuntimeValue<Driver> so that it can be safely passed between different runtime steps.
30446f5
to
a2c95c2
Compare
Merged, thanks! |
This change allows other extensions to retrieve the driver during their deployment process and use it as dependency.
Background: I'm writing another extension and I need the driver in it. So my extension will depend on Neo4j. I thought Arc respectively CDI would also allow the
Driver
to be injected, but I'm pretty sure I'm wrong on that.So with the dedicated
Neo4jDriverBuildItem
in addition to the CDI producer (both working on the sameDriver
value), the Neo4j extension provides the instance to the application and possible other extensions.