Giter VIP home page Giter VIP logo

Comments (10)

devluencer-089 avatar devluencer-089 commented on August 20, 2024 2

For lack of a better example, let's assume we have a ProductService. While the client can interact with an Observable, the server (ProductServiceImpl) has to deal with methods like this:

public void find(String customerId, Handler<AsyncResult<List<JsonObject>>> resultHandler) {

So when implementing a service in order to provide events (actually just one) to the subscriber, I would have to deal with the resultHandler. It would be much more convenient to implement a method like this:

Observable<List<JsonObject>> find(String customerId);

That way I can invoke multiple downstream services in parallel, flatMap, merge, zip and aggregate, filter,...without having to deal with Handler<AsyncResult<List<JsonObject>>> or callbacks. Having both callbacks and Observables is not what we want.
Note that I would not have to subscribe on the Observable. That could be done by the generated Proxy.

The limitations of the second point: Mocking/Testing, AOP-Proxies, Dependency Injection.

Hope this helps to understand my POV.

edit: maybe my terminology is off.
By 'client' I mean the message sender, possibly a verticle running in another vert-instance sending messages via the generated rx-wrapper facade. 'Server' refers to the message recipient. So I would see the service interface, rx-wrapper and *EBProxy as part of the client lib and the {Interface}Impl class as the server.

from vertx-service-proxy.

vietj avatar vietj commented on August 20, 2024 2

I think we should be able to generated an Rx version of the original service proxy interface that would provide hooks to implement it using RxJava, something like

interface Service {
   void foo(Handler<AsyncResult<String>> handler);
}

generates

class RxServiceAdapter implements Service{
   public void foo(Handler<AsyncResult<String>> handler) {
      // generated code that calls rxFoo()
   }
   public abstract String<String> rxFoo();
}

would that help ?

from vertx-service-proxy.

vietj avatar vietj commented on August 20, 2024

you can already use services proxies with Rx, look at this example with JDBC:

https://github.com/vert-x3/vertx-examples/blob/master/rx-examples/src/main/java/io/vertx/example/rxjava/database/jdbc/Client.java

from vertx-service-proxy.

vietj avatar vietj commented on August 20, 2024

so actually this is valid, it is just that we don't generate yet an rx version for mongo, I will add it

from vertx-service-proxy.

vietj avatar vietj commented on August 20, 2024

now it exists : vert-x3/vertx-mongo-client@2c9f0a1

the correct issue tracker would have been the vertx-mong-service project itself and now you have

public Observable<String> insertObservable(String collection, JsonObject document)

from vertx-service-proxy.

devluencer-089 avatar devluencer-089 commented on August 20, 2024

Hi Julien,

thank you for your quick response. Your average response time is faster than my last project's JEE-Server. ;-)

My question was not specific to vertx-mongo, but I will gladly use the new snapshot. Apparently I missed the VertxGen-annotation so no rx-wrapper has been created.

Unfortunately the generated wrapper object has a few drawbacks:

  • While the wrapper improves the situation on the client side (clients can now use the rx-proxy), the server side (e.g. MongoServiceImpl) still has to deal with callback-hell. My service performs calls to other "services", aggregates and filters results. That's really painful without rx-support.
  • I am now bound to a concrete implementation rather than an interface. That really puts some limitations on how we can use the proxy.

from vertx-service-proxy.

vietj avatar vietj commented on August 20, 2024

On your first point, the implementation of the server side (MongoServerImpl) can use whatever it wants. I don't see the relationship with Rx. Can you explain with more details ?

Second point : we generate a class from an interface, the generator work this way. We could have generated an rx interface and an impl too. We chosed a class because the interface does not add much. Can you clarify what you mean by "limitations" ?

from vertx-service-proxy.

xtermi2 avatar xtermi2 commented on August 20, 2024

Hi,

I would also be happy to see the feature like michaelom desciped it.

thx

from vertx-service-proxy.

UkonnRa avatar UkonnRa commented on August 20, 2024

I would also be happy to see the feature as @michaelOM mentioned also, I want to write a pure-rxjava project. Mixing up with Future and Observable is not a good idea...

from vertx-service-proxy.

Wei-Xia-Bose avatar Wei-Xia-Bose commented on August 20, 2024

Struggling with this, would like to see it in place.

There is RxHelper in Rx Java1 that can do this:
ObservableFuture<> foo = RxHelper.observableFuture();
service(foo.toHandler());

But not in RxHelper in Rx Java2. Is there alternative?

from vertx-service-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.