Simplify through use of grpc builder APIs

This commit is contained in:
Dave Syer
2024-09-09 07:17:39 +01:00
parent 4beb624978
commit 6323cf9d86
9 changed files with 76 additions and 195 deletions

View File

@@ -15,6 +15,7 @@ import org.springframework.grpc.sample.proto.HelloRequest;
import org.springframework.grpc.sample.proto.SimpleGrpc;
import org.springframework.test.annotation.DirtiesContext;
import io.grpc.Channel;
import io.grpc.Grpc;
import io.grpc.InsecureChannelCredentials;
@@ -45,11 +46,17 @@ public class GrpcServerApplicationTests {
@TestConfiguration
static class ExtraConfiguration {
@Bean
SimpleGrpc.SimpleBlockingStub stub() {
var channel = Grpc.newChannelBuilderForAddress("0.0.0.0", 9090, InsecureChannelCredentials.create())
.build();
SimpleGrpc.SimpleBlockingStub stub(Channel channel) {
return SimpleGrpc.newBlockingStub(channel);
}
@Bean(destroyMethod = "shutdown")
Channel channel() {
return Grpc.newChannelBuilderForAddress("0.0.0.0", 9090, InsecureChannelCredentials.create()).build();
}
}
}