Add basic GrpcChannelFactory implementation

This commit is contained in:
Dave Syer
2024-09-09 10:52:36 +01:00
parent 6323cf9d86
commit a406f7dc2f
5 changed files with 85 additions and 17 deletions

View File

@@ -10,15 +10,12 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.grpc.client.GrpcChannelFactory;
import org.springframework.grpc.sample.proto.HelloReply;
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;
@SpringBootTest
public class GrpcServerApplicationTests {
@@ -48,13 +45,8 @@ public class GrpcServerApplicationTests {
static class ExtraConfiguration {
@Bean
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();
SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels) {
return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:9090").build());
}
}