-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support ReactiveStreams #166
Comments
FTR, the MongoDB driver has its own RS implementation, so it's quite a popular library. |
Discussed this issue with @nmittles on the MP Context Propagation call. Here is a summary of our thoughts: This is a good idea. The duplicate interfaces in Reactive Streams and Flows are unfortunate. Long term direction will likely end up being the Flow interface that is built in to the JDK, and it will then be undesirable for the spec to have the extra dependency on reactive streams if we did this, especially for those who aren't using reactive streams. We should really avoid direct dependencies on non-JDK interfaces like this. Java EE Concurrency's ContextService.createContextualProxy actually solves the problem generically for any interface, but it comes at the cost of compiler warnings that must be suppressed when interfaces are parameterized (which applies in the case of |
Well, I disagree that it's very bad to add a dependency on a tiny lib of 4 interfaces, and the fact of the matter is that ATM nobody implements the Flow version, so if we're looking for usefulness we can skip the JDK9 version for quite some time. |
Given other discussions at the Architecture level discussing switching to a JDK 11 base, as opposed to JDK 8, I see it as being a couple of years before we based on a JDK that includes To that end, I don't think worrying about an "extra dependency" several years down the road should prevent this work from happening now |
I'm not suggesting that we prevent this work from being done, just that we explore a more generic solution that solves it for both Flow and ReactiveStreams plus other generic interfaces that can benefit from contextualization. |
I think it is pretty safe to add a dependency on I agree with @kenfinnigan and @FroMage that we shouldn't worry about Flow because we will require JDK 8 interop for a long time still. To illustrate what I think what @njr-11 is proposing -- instead of having:
We combine these into 1 generic method such as:
I prefer the type-safe individual methods, which IMO makes the API easier to understand/use. However, we could also add the generic method as a safety-net if any new interfaces pop up in the future in between spec releases. To avoid method signature conflicts we could adjust the signature of the generic method to: |
I was thinking of something more like this, which is generic, but still properly typed (we can figure out the correct method name later),
The above would make the following possible, without any compiler warnings, and without introducing any dependencies to the spec,
If we can introduce something generic and simple that doesn't require dependencies, I don't see why we would take a different approach that does. |
OK, thanks, I understand now. But I'm not sure if we can implement context capturing generically. See |
I agree - the general pattern covers a core set of common usage, which is contextualizing interface methods (works well for Subscriber, and many other interfaces). There are certainly a number of special-cased patterns such as our withContextCapture(stage/future) methods which cause the resulting object to do something special with respect to context propagation (which for |
Signed-off-by: Nathan Rauh <[email protected]>
Although the plugin system of MP-CP and RxJava2 make it possible to have automatic context propagation for RxJava2, it appears some ReactiveStreams implementations don't use RxJava2 or Reactor but built their own implementations, which don't necessarily have a plugin system and so must be manually embarked into context propagation.
We could add those methods to
ThreadContext
:At the cost of a dependency to ReactiveStreams, but that's an industry standard and has 4 interfaces. We could add support for the JDK 9's Flow.Subscriber too, but I don't think we can add a dependency to JDK9.
The text was updated successfully, but these errors were encountered: