-
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 - introduce the CurrentContextFactory abstraction #22319
Conversation
The workflow is simple: the request context will use a ContextReference created via the ContextReferenceFactory. The default impl is using |
Hm, maybe |
I think this looks good. I will look at building on top of this. |
👍 |
+1, this looks great.
I'd prefer One more note - the |
It is in ArC... Do you mean the |
Yes, I meant the API package but failed to mention it, sorry.
Ok, fair enough, I didn't realize that. Consider my complaint obsolete :-) |
SR-CP had this already created in a new Maven project with zero dependency: The idea was that you declared your storage need with https://github.com/smallrye/smallrye-context-propagation/blob/main/storage/src/main/java/io/smallrye/context/storage/spi/StorageDeclaration.java which allowed our extension to pick up all storage slots: FroMage@b90e4e5 Here's how ArC could then declare its storage requirements and use the new storage: FroMage@372c229 Note that we went with |
On non-Quarkus, the default storage manager hands out real But for Quarkus, the ThreadLocals will store stuff in custom thread fields: FroMage@b90e4e5#diff-f36606de9fadce013fb441b209205c1ff4b55eaae93d2a1d5c3fa7549e6003ecR100 . We only have to change that to store them in the Vert.x context. |
This abstraction is an ArC-specific bit that is only used by ArC contexts. I don't want to add the |
Well, how do you get other projects to use the ArC storage then if there's no module they can import to get it? |
I'm not sure I understand. Other projects can simply use the beans stored in the CDI contexts. We don't want them to use the ArC internals... |
Here is something (a bit hacked up) built on top of this that should be suitable for testing: The interesting bit here is that to get the result we want we need to effectively deliberately 'leak' the context by ignoring the 'remove' method. As we know the context is tied to the request this should be safe, as the data will now have the same lifecycle as the context data. @Sanne any chance you could benchmark this? |
That's precisely my point: we have an independent module already with zero dependencies, that abstracts |
Well, this PR does not prevent this solution except that I want to have the ArC core more pluggable and not tied to the API of the |
But |
Almost. A |
d148339
to
77fc6b2
Compare
@mkouba @Sanne @stuartwdouglas I have rebased this branch and resolved conflicts with the recent changes to req. context propagation. I think we should restart the discussion here as this is still a valuable addition. Some time ago, Stuart created a testable PoC for this PR, see #22319 (comment) We can still take that commit and slap it on top of this rebased branch just fine. |
77fc6b2
to
2a358ec
Compare
I've rebased this PR one more time and also renamed the Unfortunately, this means that Stuart's PoC would have to be rebased as well. In any case, I believe that this abstraction makes a lot of sense and I'd like to have it merged no matter whether we'll have some benchmarks available or not (and given the current workload it seems that we won't have them any time soon ;-). |
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 a few suggestions to unify naming, otherwise LGTM!
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ArcContainerImpl.java
Outdated
Show resolved
Hide resolved
...dent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/ThreadLocalContextReference.java
Outdated
Show resolved
Hide resolved
...ojects/arc/runtime/src/main/java/io/quarkus/arc/impl/ThreadLocalContextReferenceFactory.java
Outdated
Show resolved
Hide resolved
2a358ec
to
68ecfbd
Compare
Thanks. Comments are addressed. |
98efb9a
to
8451be9
Compare
- this API allows quarkus to supply an optimized backend for a context of a normal scope - currently it's only used by the request context - an extension can provide a custom factory via CurrentContextFactoryBuildItem
8451be9
to
db7c71d
Compare
awesome, thanks! |
non-shared context of a normal scope
ContextReferenceFactoryBuildItem