jdaugherty opened a new issue, #16621:
URL: https://github.com/apache/grails-core/issues/16621

   ## Summary
   
   `grails-datamapping-rx` (RxGORM) contains two separable things:
   
   1. **RxJava data services.** A `@Service` interface or `@RxSchedule` method 
that returns `Observable<T>` or `Single<T>` runs the blocking GORM operation on 
the RxJava IO scheduler. This works with every GORM datastore (Hibernate, 
MongoDB, Neo4j, the in-memory simple map) and is covered by `RxServiceImplSpec` 
against a plain `@Entity`. It is documented in the "RxJava Data Services" page 
of the Hibernate guides.
   2. **The `RxEntity` reactive domain model.** A domain class implements 
`grails.gorm.rx.RxEntity` instead of `GormEntity`; `get()`, `save()`, dynamic 
finders, the reactive `DetachedCriteria`, `ObservableProxy` associations and 
lazy `RxPersistentSet`/`List`/`SortedSet` collections all return RxJava types 
and drive everything through an `RxDatastoreClient`. The module ships only 
`AbstractRxDatastoreClient`; a datastore has to supply `batchWrite`, 
`batchDelete`, `createEntityQuery`, `generateIdentifier` and `doClose` on a 
non-blocking driver.
   
   This proposes removing the second part in Grails 9 and keeping the first.
   
   ## History: the only implementation has been gone since 2018
   
   - RxGORM and RxGORM for MongoDB were introduced together in GORM 6.0 
(`grails-datastore-gorm-rx` and `grails-datastore-gorm-rx-mongodb` 6.0.0.M1, 
May 2016). MongoDB was the only datastore ever implemented, on the RxJava 1 
`mongodb-driver-rx`.
   - `grails-datastore-gorm-rx-mongodb` was last published as 6.1.6.RELEASE on 
2018-06-15; the `v6.1.7` tag (December 2018) was never released to Maven 
Central. The `org.grails.plugins:rx-mongodb` plugin coordinate, which the 
`rx-mongodb` profile feature still generates into applications, has never 
existed on Maven Central at all.
   - The `grails/gorm-mongodb` repository removed its rx modules on 2018-12-11 
(commit `0e3fad24fc`, "remove rx modules"), before GORM 7.0.0. GORM MongoDB 7.x 
and 8.x and the monorepo's `grails-data-mongodb` have no RxGORM implementation.
   - The RxJava 1 MongoDB driver that implementation was built on has itself 
been discontinued; a new implementation would be a rewrite on the 
reactive-streams driver, not a port.
   - RxGORM core kept being published (`grails-datastore-gorm-rx` up to 
9.0.0-M2, now `grails-datamapping-rx` in the monorepo), so the `RxEntity` API 
has existed for seven years with nothing behind it. Its own test suite 
exercises it only through mocked and stubbed `RxDatastoreClient`s.
   - #14613 (RxJava 2 support, open since 2017) was never acted on; #16619 
ports the module to RxJava 3, which makes the API current but does not change 
the fact that no datastore implements it.
   
   ## It cannot be implemented on Hibernate
   
   `RxEntity` is only meaningful on a driver with non-blocking I/O; that was 
its whole point over the `GormEntity` async API, which merely moves a blocking 
call to another thread. GORM for Hibernate is built on Hibernate ORM's blocking 
`Session` over JDBC, which has no non-blocking mode. Hibernate Reactive is a 
separate project on Vert.x with its own session API, no JDBC, no second-level 
cache, and a different programming model (`CompletionStage`/Mutiny), so an 
`RxDatastoreClient` on top of it would be a new datastore rather than an 
extension of GORM for Hibernate, and it would still have to be wrapped back 
into RxJava types. Nobody has proposed doing that in the eight years the API 
has existed, and the data services path already gives Hibernate users reactive 
signatures over the blocking engine, which is the only thing Hibernate ORM can 
offer.
   
   ## Proposal
   
   For Grails 9.0:
   
   - Remove the `RxEntity` domain model and its machinery from 
`grails-datamapping-rx`: `grails.gorm.rx.RxEntity`, `MultiTenant`, 
`DetachedCriteria`, `CriteriaBuilder`, `PersistentObservable`, the 
`grails.gorm.rx.api`, `collection`, `proxy` and `multitenancy` packages, 
`org.grails.datastore.rx.*` (`RxDatastoreClient`, `AbstractRxDatastoreClient`, 
batch, collection, proxy, query), `org.grails.gorm.rx.api`, `events` and 
`finders`, and the `RxEntity` branch in `GormEntityTransformation`.
   - Keep `grails-datamapping-rx` as the home of the RxJava data services: 
`grails.gorm.rx.services.RxSchedule`, `RxScheduleIOTransformation`, 
`RxAstUtils`, `RxServiceSupport` and the 
`ObservableResultAdapter`/`SingleResultAdapter` service implementers. Possibly 
rename the module to say what it is, with the old coordinate relocated through 
the BOM.
   - Remove the `rx-mongodb` profile feature, which generates a dependency on 
an artifact that has never been published.
   - Replace the RxGORM user guide (`grails-data-docs/guide-rx`) and the 
"RxGORM" page of the Async chapter with the data services documentation. The 
Async chapter's "RxJava" and "Server Sent Events" pages also point at the 
`grails-rxjava` controller plugin, last pushed in February 2019, under an 
`org.apache.grails:grails-rxjava3` coordinate that does not exist; they need 
the same decision.
   - Document the removal in the Grails 8 to 9 upgrade guide and the 
`grails-9-upgrade` skill: an application that implements `RxEntity` has had no 
working datastore since Grails 3, so the migration is to `GormEntity` with 
RxJava data services.
   
   Because #16619 has already moved the module to RxJava 3, the data services 
keep working on RxJava 3 after the removal, and the removal can be a follow-up 
PR against 9.0.x without blocking that one.
   
   ## Alternative considered
   
   Writing a new RxGORM for MongoDB on the reactive-streams driver inside the 
monorepo. It would be the only implementation, for one datastore, of an API 
that has had no users able to run it since 2018, and it would have to be 
maintained alongside GORM for MongoDB's existing Spring Data MongoDB 
interoperability. The data services path already gives MongoDB applications 
reactive signatures. The cost is hard to justify.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to