grpc-spring-boot-starter icon indicating copy to clipboard operation
grpc-spring-boot-starter copied to clipboard

Allow to use Reactor Flux or RxJava Observable instead of gRPC StreamObserver

Open sdeleuze opened this issue 10 years ago • 20 comments

Allow to use Reactive types like Reactor Flux or RxJava Observable instead of dealing direction with gRPC StreamObserver would be awesome for the end user, and since gRPC supports Backpressure that would be a very good match.

Integration with single value types like Reactor Mono or RxJava Single would also be really useful.

Maybe @saturnism has some ideas about how to achieve this since this is one of the topic or his upcoming Spring I/O talk ...

sdeleuze avatar Apr 12 '16 08:04 sdeleuze

One possible solution would be to have protoc generator plugin that will wrap all generated interfaces with Observable instead of StreamObserver. There is already one that does this to bridge rest api with grpc. @sdeleuze ,what is your opinion about this approach ?

jvmlet avatar Apr 14 '16 14:04 jvmlet

I'm totally in favour of using Reactor types instead of native gRPC types. But, I would question that this is the responsibility of a spring-boot-starter.

otrosien avatar Jun 13 '16 06:06 otrosien

Indeed, that's maybe out of the scope of this starter, that would make more sense if available as a distinct artifact. I have no time to develop that myself, but @smaldini and I could provide some guidance if a contributor is interested.

sdeleuze avatar Jun 13 '16 08:06 sdeleuze

I would be interested in hearing your opinion about having protoc plugin proposed earlier in this thread

jvmlet avatar Jun 13 '16 12:06 jvmlet

As @sdeleuze said, make it a separate artifact then, and don't mix it with the spring-boot-starter.

otrosien avatar Jun 13 '16 12:06 otrosien

I totally understand that the bridge would be the separate artifact, I'm trying to do a brainstorming to accomplish the solution. My proposal is to implement protoc plugin that will generate the abstract implementation of gRPC interfaces with Reactive types, then the end user can decide which API he is more comfortable with and for using reactive types he will add protoc plugin in his gradle/maven build. I want to understand the concept of solution that @sdeleuze has in mind.

jvmlet avatar Jun 14 '16 07:06 jvmlet

:+1:

cbornet avatar Jan 24 '17 21:01 cbornet

See https://github.com/salesforce/grpc-java-contrib/pull/17 for a rxjava2 integration passing the rx stream TCK. Could be a good base for a Reactor implementation.

cbornet avatar Oct 06 '17 06:10 cbornet

@cbornet ,Looks great, thanks for sharing. Which functionality/features this starter should include in addition to samples of Rx java usage based on saleforce protoc plugin ?

jvmlet avatar Oct 06 '17 10:10 jvmlet

great stuff @cbornet would love to see how we can plug in the lite cousin of rx especially for direct interop with spring fmk 5/spring boot 2

smaldini avatar Oct 06 '17 17:10 smaldini

Yes, I'm not sure there's anything to do for RxJava/Reactor in this project. I've tested and salesforce plugin + this starter works out-of-the-box. So the Reactor plugin should probably be done in another project.

cbornet avatar Oct 13 '17 10:10 cbornet

I think this issue can be closed as @cbornet is already working on this feature in https://github.com/cbornet/grpc-java-contrib/tree/reactor , tracked in https://github.com/salesforce/reactive-grpc/issues/6

dadadom avatar Nov 09 '17 12:11 dadadom

@cbornet so you're using grpc-spring-boot-starter together with https://github.com/salesforce/reactive-grpc/issues/6 ? Isn't their impl built on (along with) separate generated 'reactor' Grpc services, + defining their own custom @GrpcService?

hartmut-co-uk avatar Jan 20 '18 18:01 hartmut-co-uk

@hartmut-co-uk yes I confirm they work perfectly together. The custom @GrpcService is in another salesforce lib.

cbornet avatar Jan 20 '18 19:01 cbornet

@cbornet 👍 thanks - will have another look! :-)

hartmut-co-uk avatar Jan 20 '18 23:01 hartmut-co-uk

almost forgot to update.. works like a charm!

hartmut-co-uk avatar Jan 23 '18 17:01 hartmut-co-uk

does this still apply today? is there a sample project that's available that shows this integration between the grpc-spring-boot-starter and reactive-grpc?

dalegaspi avatar Sep 12 '22 15:09 dalegaspi

@dalegaspi https://github.com/salesforce/reactive-grpc

jvmlet avatar Sep 12 '22 16:09 jvmlet

@jvmlet i downloaded and searched the entire repo none of the demos (or anything for that matter) references the grpc-spring-boot-starter in the pom.xml file(s). should i be looking for something else entirely?

Edit: so the reactive-grpc stuff creates the Reactive stub methods(s) and it just works from the looks of it.

dalegaspi avatar Sep 12 '22 16:09 dalegaspi

https://github.com/salesforce/reactive-grpc/tree/master/demos/hello-world. Have a look at protoc plugin this project uses in pom file. The server side implementation is not tied to any specific helper, including this starter, as long as it properly binds to grpc api. As it was mentioned above, you can implement the server using this starter (which makes your life easier) and benefit both from spring and rx technologies.

jvmlet avatar Sep 13 '22 03:09 jvmlet