Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support to Spring Webflux (reactive handlers) #331

Closed
atrujillofalcon opened this issue Aug 1, 2018 · 16 comments · Fixed by #708
Closed

Support to Spring Webflux (reactive handlers) #331

atrujillofalcon opened this issue Aug 1, 2018 · 16 comments · Fixed by #708
Labels
Milestone

Comments

@atrujillofalcon
Copy link
Contributor

Logbook already has Spring support to traditional controllers model. In Spring Boot 2.X was introduced the reactive programming model with spring-webflux. Would be nice have Logbook support to this approach

See more details of Webflux here: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#spring-webflux

Context

I use Logbook for many micro-services in my job. We need to integrate Logbook in some reactive webflux services.

Possible Implementation

By WebHandler API? -> https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-web-handler-api

Thanks for your attention.
Greetings!

@whiskeysierra
Copy link
Collaborator

The traditional, blocking approach is supported via a Servlet Filter, which has the nice benefit of not being tied to Spring directly, i.e. it's useful for other frameworks as well.

Is there a usable, standardized API for nio that Spring is using?

@whiskeysierra
Copy link
Collaborator

https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-httphandler sounds like a good start. But also looks like there is no common API.

@atrujillofalcon
Copy link
Contributor Author

atrujillofalcon commented Aug 2, 2018

I see your point. Spring Webflux is built on Project Reactor so we can built the reactive Filter using a common API like CompletableFuture's or RxJava because this libraries are compatible with Project Reactor. Could you give me more details on how the current Logbook integration with Spring works?

@whiskeysierra
Copy link
Collaborator

It's basically just a servlet filter, see https://github.com/zalando/logbook/tree/master/logbook-servlet, that we register using Spring's FilterRegistrationBean.

@atrujillofalcon
Copy link
Contributor Author

Let me think of an approach, and I'll let you know if I can come up with a standard solution.

@atrujillofalcon
Copy link
Contributor Author

A question, the logbook-core module is not tied to the servlet API? In this case, would it be possible to create a new module called spring-webflux or something similar?

@whiskeysierra
Copy link
Collaborator

the logbook-core module is not tied to the servlet API

True.

In this case, would it be possible to create a new module called spring-webflux or something similar?

Possible, yes. But I'd prefer a solution that is not tied to spring.

@fragonib
Copy link

+1

@whiskeysierra whiskeysierra added this to the 2.1.0 milestone Sep 3, 2019
@gmariotti
Copy link

Not sure if this feature is still under consideration, but creating a Netty module would make this library easy to use also for Vert.x and Quarkus.

@whiskeysierra
Copy link
Collaborator

Not sure if this feature is still under consideration, but creating a Netty module would make this library easy to use also for Vert.x and Quarkus.

That sounds promising then. Normally I'm opposed to bind myself to an implementation, but in this case it seems that Netty is pretty much the NIO framework of choice and we would cover the following application frameworks:

  • Spring WebFlux
  • Micronaut
  • Vert.x
  • Quarkus

@whiskeysierra
Copy link
Collaborator

Anyone here who has experience customizing the netty setup (preferably adding custom channel handlers) for Vert.x, Quarkus and/or Micronaut?

@whiskeysierra
Copy link
Collaborator

whiskeysierra commented Feb 2, 2020

@gmariotti
Copy link

I think Quarkus is running on top of Vert.x so, it might have the same problem. If Micronaut is planning to support it, I would still go for a Netty module, otherwise doing a Spring WebFlux specific one is easier.

@whiskeysierra
Copy link
Collaborator

I already have a working Netty-based solution locally. I wanted to add tests for each framework. Spring works, but I stumpled for the other three.

@gmariotti
Copy link

That's great!! Is it something you can share already? I would be interested to see if I can create a similar module for Vert.x

@whiskeysierra
Copy link
Collaborator

I pushed my current branch here: https://github.com/zalando/logbook/tree/feature/netty/logbook-netty/src/main/java/org/zalando/logbook/netty

Maybe the existing API for vert.x already allows enough to register it? See http://www.julienviet.com/advanced-vertx-guide/#integrating-netty

whiskeysierra added a commit that referenced this issue Feb 11, 2020
@whiskeysierra whiskeysierra mentioned this issue Feb 11, 2020
6 tasks
whiskeysierra added a commit that referenced this issue Feb 11, 2020
whiskeysierra added a commit that referenced this issue Feb 11, 2020
whiskeysierra added a commit that referenced this issue Feb 11, 2020
whiskeysierra added a commit that referenced this issue Feb 11, 2020
whiskeysierra added a commit that referenced this issue Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants