Add reflection service to grpc server
User can now inspect service definitions (e.g. with grpcurl).
This commit is contained in:
@@ -31,6 +31,11 @@
|
||||
<artifactId>grpc-protobuf</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-services</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-stub</artifactId>
|
||||
|
||||
@@ -19,13 +19,15 @@ package org.springframework.cloud.function.grpc;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import io.grpc.BindableService;
|
||||
import io.grpc.Server;
|
||||
import io.grpc.ServerBuilder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import io.grpc.protobuf.services.ProtoReflectionService;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -58,6 +60,9 @@ class GrpcServer implements SmartLifecycle {
|
||||
BindableService bindableService = this.grpcMessageServices[i];
|
||||
serverBuilder.addService(bindableService);
|
||||
}
|
||||
if (ClassUtils.isPresent("io.grpc.protobuf.services.ProtoReflectionService", null)) {
|
||||
serverBuilder.addService(ProtoReflectionService.newInstance());
|
||||
}
|
||||
this.server = serverBuilder.build();
|
||||
|
||||
logger.info("Starting gRPC server");
|
||||
|
||||
Reference in New Issue
Block a user