Skip to content

Commit e3ff1be

Browse files
committed
use enum for health type
1 parent c7f8845 commit e3ff1be

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/autoconfigure/GrpcHealthServiceAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ HealthStatusManager healthStatusManager() {
5757

5858
@Bean
5959
@GrpcService
60-
@ConditionalOnProperty(prefix = "grpc.server", name = "health-service-type", havingValue = "grpc", matchIfMissing = true)
60+
@ConditionalOnProperty(prefix = "grpc.server", name = "health-service-type", havingValue = "GRPC", matchIfMissing = true)
6161
BindableService grpcHealthService(final HealthStatusManager healthStatusManager) {
6262
return healthStatusManager.getHealthService();
6363
}
6464

6565
@Bean
6666
@GrpcService
67-
@ConditionalOnProperty(prefix = "grpc.server", name = "health-service-type", havingValue = "actuator")
67+
@ConditionalOnProperty(prefix = "grpc.server", name = "health-service-type", havingValue = "ACTUATOR")
6868
@ConditionalOnBean(HealthEndpoint.class)
6969
BindableService grpcHealthServiceActuator(final HealthEndpoint healthStatusManager) {
7070
return new ActuatorGrpcHealth(healthStatusManager);

grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/config/GrpcServerProperties.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ public class GrpcServerProperties {
229229
private boolean healthServiceEnabled = true;
230230

231231
/**
232-
* @TODO
232+
* Implementation of gRPC health service. Defaults to {@link HealthType#GRPC GRPC}.
233+
*
234+
* @param healthServiceType The implementation of gRPC health service.
235+
* @return GRPC or Actuator.
233236
*/
234-
private String healthServiceType = "grpc";
237+
private HealthType healthServiceType = HealthType.GRPC;
235238

236239
/**
237240
* Whether proto reflection service is enabled or not. Defaults to {@code true}.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.devh.boot.grpc.server.config;
2+
3+
/**
4+
* Enum to specify the type of health service to use in GRPC.
5+
*/
6+
public enum HealthType {
7+
/**
8+
* Use the standard GRPC health service from io.grpc.
9+
*/
10+
GRPC,
11+
/**
12+
* Uses a bridge to the Spring Boot Actuator health service.
13+
*/
14+
ACTUATOR
15+
}

grpc-server-spring-boot-starter/src/test/java/net/devh/boot/grpc/server/autoconfigure/GrpcHealthServiceTrueActuatorConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
GrpcHealthServiceTrueActuatorConfigurationTest.TestConfig.class
4343
},
4444
properties = {
45-
"grpc.server.health-service-type=actuator",
45+
"grpc.server.health-service-type=ACTUATOR",
4646
})
4747
@ImportAutoConfiguration({
4848
GrpcServerAutoConfiguration.class,

0 commit comments

Comments
 (0)