* Conditional changes in grpc auto configuration
* Modifier changes in GrpcAutoConfiguraiton for extensibility
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import io.grpc.BindableService;
|
import io.grpc.BindableService;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cloud.function.context.FunctionCatalog;
|
import org.springframework.cloud.function.context.FunctionCatalog;
|
||||||
@@ -37,7 +38,7 @@ import org.springframework.util.StringUtils;
|
|||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableConfigurationProperties(FunctionGrpcProperties.class)
|
@EnableConfigurationProperties(FunctionGrpcProperties.class)
|
||||||
@ConditionalOnProperty(name = "spring.cloud.function.grpc.server", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "spring.cloud.function.grpc.server", havingValue = "true", matchIfMissing = true)
|
||||||
class GrpcAutoConfiguration {
|
public class GrpcAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GrpcServer grpcServer(FunctionGrpcProperties grpcProperties, BindableService[] grpcMessagingServices) {
|
public GrpcServer grpcServer(FunctionGrpcProperties grpcProperties, BindableService[] grpcMessagingServices) {
|
||||||
@@ -53,8 +54,9 @@ class GrpcAutoConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings("rawtypes")
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
public BindableService grpcSpringMessageHandler(MessageHandlingHelper helper) {
|
public BindableService grpcSpringMessageHandler(MessageHandlingHelper helper) {
|
||||||
return new GrpcServerMessageHandler(helper);
|
return new GrpcServerMessageHandler(helper);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ import com.google.protobuf.GeneratedMessageV3;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
class GrpcServerMessageHandler extends MessagingServiceImplBase {
|
public class GrpcServerMessageHandler extends MessagingServiceImplBase {
|
||||||
|
|
||||||
private Log logger = LogFactory.getLog(GrpcServerMessageHandler.class);
|
private Log logger = LogFactory.getLog(GrpcServerMessageHandler.class);
|
||||||
|
|
||||||
@@ -78,8 +78,7 @@ class GrpcServerMessageHandler extends MessagingServiceImplBase {
|
|||||||
|
|
||||||
private boolean running;
|
private boolean running;
|
||||||
|
|
||||||
|
public GrpcServerMessageHandler(MessageHandlingHelper<GeneratedMessageV3> helper) {
|
||||||
GrpcServerMessageHandler(MessageHandlingHelper<GeneratedMessageV3> helper) {
|
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user