* Conditional changes in grpc auto configuration

* Modifier changes in GrpcAutoConfiguraiton for extensibility
This commit is contained in:
Soby Chacko
2023-05-15 18:18:23 -04:00
parent 4655f7089e
commit f4d4eba233
2 changed files with 6 additions and 5 deletions

View File

@@ -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);
} }

View File

@@ -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;
} }