Comments (9)
This is a bit of a pain point, to be sure. The idea is to provide an easy use of the framework without having to explicitly start the Dispatching components. But we also don't want them always started because we might be operating in an environment where we'll manage that ourselves (multiple classloading scenario comes to mind here). So we want to do both with as little pain as possible and not have to impose a doInReactor
style callback where you can only run code without our strict environment.
Ideally, we should be able to run code from Java main and It Just Works.
from reactor.
R
is involved in this too. It relies on Context
's static initializer having run to initialize self
. Prior to 678026b R
had no dependency on Context
so the following test run on its own would fail:
@Test
public void createAReactor() {
R.create();
}
678026b inadvertently "fixed" this. Rather than creating a new SynchronousDispatcher
, it now uses Context
's instead. However, there's now a circular dependency between the two:
- R.class is loaded
- Its
<clinit>
callsContext.synchronousDispatcher
- Context.class is loaded
- Its
<clinit>
callsinit
which instantiates an instance ofR
and passes it toR.assignR
which setsself
onR
from reactor.
If auto-initialisation is disabled (by setting the reactor.init.auto
system property to false
), things are really broken:
Context
will never instantiateR
or callR.assignR
, renderingR
useless.Context
'sself
will never be set making all of itsDispatchers
inaccessible
from reactor.
This is quite critical, we need to fix that. I failed at providing a right solution without sacrificing convenient API :(
from reactor.
Can we do lazy initialization and throw an exception if we're not supposed to auto-init based on the system property?
from reactor.
I'm going to explore an approach to this along these lines:
- Global automatically-initialised
Context
. Can be disabled with a system property. R
uses the globalContext
. If you've disabled it, you can't useR
(or we could let people create and set a globalContext
)- Everything else that relies on
Context
then needs to be able to be given one when it's created, or if it's not given one use the global one. For things likeComposable
where we might be creating an Observable from another one, it needs to inherit theContext
.
from reactor.
To add some complications to this task: it's very easy to shoot yourself in the foot and create an application that notifies internal Reactors, adds data to Composables and otherwise does normal asynchronous tasks, but if you're not careful with how you nest these objects, where you create them, what Dispatcher you give them, and when you call accept, the application can suffer from race conditions, particularly around updating shared Composables and notifying a Reactor from inside a consumer on that Reactor.
It would be great to have a builder API that would allow you to build a Composable, say, that was properly configured for using from inside a Reactor's Consumer and other tasks where setting up several Reactor-based components are needed to work together.
from reactor.
To even further complicate this, I think we need to consider static state as a whole as part of this tidy up. I'm currently leaning towards removing all static state: it over-complicates things and seems like a recipe for classloading-related confusion. We'd lose the R
helper class (in its current form, at least) but I think that's a price worth paying.
from reactor.
All static state has been removed from Reactor in 58bd8aa (I forgot to reference this issue in the commit message).
from reactor.
Related Issues (20)
- Allow signed releases to Artifactory from GitHub Actions HOT 4
- Remove explicit occurrences of jcenter from build HOT 2
- Release: move tagging step at the end
- Use Spotless plugin to help enforce basic formatting / license HOT 3
- Use Spotless plugin to enforce and update copyright headers HOT 1
- [Reactor Gen4] Discussing switching to a JDK 17 baseline HOT 41
- [Reactor Gen4] Ensuring Reactor 3 can run along Reactor 4 HOT 13
- [Reactor Gen4] The Rationale for a Generation 4 of Reactor HOT 3
- Use Gradle 7.3 HOT 1
- Reproducible Builds
- Remove the Reactive Streams Commons from README.md
- Is there any connection between org.projectreactor:reactor-core and io.projectreactor:reactor-core ? HOT 2
- Incompatible reactor-kotlin-extensions used in 2020.0.x BOM HOT 1
- Add new module reactor-core-micrometer to 2022.0.0-M3 BOM
- No dependency management for `reactor-tools` with classifier `original` HOT 1
- Builds with japicmp should set onlyModified = true / onBinaryIncompatibleModified = false
- Update GHA workflows to avoid warnings around output APIs HOT 1
- Did we have some tools like Java-profilers for perfomance or cost analyzing?
- Consider enabling discussions tab on GitHub
- reactor-tools original classifier should also be part of the BOM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactor.