micronaut-projects / micronaut-grpc

Integration between Micronaut and GRPC
Apache License 2.0
67 stars 38 forks source link

Use InProcessServerBuilder for testing #213

Open asarkar opened 4 years ago

asarkar commented 4 years ago

Micronaut gRPC creates a NettyServerBuilder automatically. How do I use an InProcessServerBuilder for testing?

One way is to set grpc.server.enabled=false, and then create the Server myself.

Server server = InProcessServerBuilder.forName(uniqueName)
      .directExecutor()
      .addService(new MyService())
      .build().start();

But then, I've to start and stop it. It'd be nice to have the framework manage it on my behalf instead.

jntakpe commented 4 years ago

Actually I struggled with that, indeed it'd be nice if the framework manages a proper way to mock Grpc services

asarkar commented 4 years ago

grpc-spring-boot-starter does this using a property.

asarkar commented 3 years ago

@graemerocher I'm willing to submit PR for this, but there will have to be internal design changes. I looked at the code, and it assumes NettyServerBuilder. I'm thinking something like shown in this ticket, so that the builder can be configured using external properties.

Do you've any thoughts on this?

graemerocher commented 3 years ago

Seems reasonable