datastax / cassandra-quarkus

An Apache Cassandra(R) extension for Quarkus
Apache License 2.0
40 stars 28 forks source link

[JAVA-2754] Integration between Driver reactive API and Quarkus #35

Closed adutra closed 4 years ago

adutra commented 4 years ago

Imported from [JAVA-2754](https://datastax-oss.atlassian.net/browse/JAVA-2754), originally reported by tomekl007 on Tue, 28 Apr 2020 12:21:01 GMT.


Quarkus is using

<dependency>
    <groupId>io.smallrye.reactive</groupId>
    <artifactId>mutiny-rxjava</artifactId>
</dependency>

For reactive API.
(see [https://quarkus.io/guides/getting-started-reactive](https://quarkus.io/guides/getting-started-reactive))
We should provide converters between reactive constructs used in the java-driver (Reactor, rx) to quarkus mutiny API.
Once it will be done, the quick-start project should be enhanced with a reactive example, this code could be used:
https://github.com/datastax/cassandra-quarkus/compare/java2683_async?expand=1

┆Issue is synchronized with this Jira Task by Unito

adutra commented 4 years ago

Imported from JAVA-2754, originally commented by @tomekl007 on Tue, 5 May 2020 07:46:00 GMT.


We should be able to integrate with https://quarkus.io/guides/reactive-routes

adutra commented 4 years ago

Imported from JAVA-2754, originally commented by @tomekl007 on Thu, 14 May 2020 11:03:57 GMT.


When investigating the JAVA-2754 Reviewing , I found this smallrye-mutiny-vertx-cassandra-client:
https://github.com/vert-x3/vertx-cassandra-client (it uses java driver 4.x)
https://github.com/vert-x3/vertx-cassandra-client/blob/master/src/main/java/io/vertx/cassandra/impl/CassandraClientImpl.java
So it seems that vertx has a cassandra-client that works in a reactive way.
It seems that Vert.x reactive client can be used with quarkus:
https://quarkus.io/guides/getting-started-reactive#using-vert-x-clients

I don’t know how does it compare with our extension?
It seems that our extension has a different purpose ( it was upvoted multiple times here:
https://github.com/quarkusio/quarkus/issues/7876#issue-582099130)) so I think it is needed.
But now I don’t fully understand how does it compare to the reactive solution that is already out there (and uses Vertx)

It seems that for mongo, there is also a similar smallrye reactive client
io.smallrye.reactive:smallrye-mutiny-vertx-mongo-client
but the mongo extension is re-implementing that (see ReactiveMongoClientImpl)

Should we follow the same path and just implement reactive wrappers around our client?

adutra commented 4 years ago

Imported from JAVA-2754, originally commented by @adutra on Thu, 14 May 2020 11:53:51 GMT.


When we look into the vertex-cassandra-client project, CasasandraClientImpl is not "reactive", at least not in the sense that it implements the ReactiveStreams API. It seems this client is essentially using the driver async API.

When looking into vertx-mutiny-cassandra-client project, the only thing it contains is this test: https://github.com/smallrye/smallrye-reactive-utils/blob/master/vertx-mutiny-clients/vertx-mutiny-cassandra-client/src/test/java/io/vertx/mutiny/cassandra/CassandraClientTest.java.

So, I'm not an expert in Vertex or Mutiny, but I think we should still provide something that looks closer to our ReactiveResultSet and offers some backpressure guarantees.

adutra commented 4 years ago

Pull request URL imported from JAVA-2754: datastax/cassandra-quarkus/pull/11.