Skip to content

Conversation

@dsyer
Copy link
Member

@dsyer dsyer commented Oct 23, 2024

In a web application, if there are BindableServices we use
a servlet instead of a netty-based server.

Fixes #18

@dsyer dsyer requested a review from onobc October 23, 2024 10:19
@dsyer dsyer force-pushed the tomcat branch 3 times, most recently from 4cab4b2 to 25b384b Compare October 23, 2024 10:25
Copy link
Contributor

@onobc onobc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool stuff @dsyer . I have added a few comments/concerns.


@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication
static class GrpcServletConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are limited options for the ServletServerBuilder so providing a custom server factory is overkill since the ServletAdapter#init does the same thing we would be doing:

  public GrpcServlet(List<? extends BindableService> bindableServices) {
    this(loadServices(bindableServices));
  }

  private static ServletAdapter loadServices(List<? extends BindableService> bindableServices) {
    ServletServerBuilder serverBuilder = new ServletServerBuilder();
    bindableServices.forEach(serverBuilder::addService);
    return serverBuilder.buildServletAdapter();
  }

@dsyer dsyer force-pushed the tomcat branch 2 times, most recently from ab2f005 to 401188e Compare October 24, 2024 07:37
@dsyer dsyer merged commit b5a6232 into spring-projects:main Oct 25, 2024
2 checks passed
@dsyer dsyer deleted the tomcat branch October 25, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support using the same port for Spring MVC and gRPC

2 participants