Skip to content

Commit 9642e00

Browse files
onobcdsyer
authored andcommitted
Generate metadata for config props
Adds the `spring-boot-configuration-processor` to enable automatic metadata generation so our config props play well in IDEs. Also updates the default values for duration properties to use `Duration.of<Unit>(long)` instead of `Duration.of(long, DurationUnit)` as Spring Boot config processor can not determine a default for the config metadata in the latter format.
1 parent 9bcc339 commit 9642e00

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spring-grpc-spring-boot-autoconfigure/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222

2323
<dependencies>
2424

25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-configuration-processor</artifactId>
28+
<optional>true</optional>
29+
</dependency>
30+
2531
<dependency>
2632
<groupId>com.google.protobuf</groupId>
2733
<artifactId>protobuf-java</artifactId>

spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServerProperties.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public class GrpcServerProperties {
4949
* shutdown immediately. The default is 30 seconds.
5050
*/
5151
@DurationUnit(ChronoUnit.SECONDS)
52-
private Duration shutdownGracePeriod = Duration.of(30, ChronoUnit.SECONDS);
52+
private Duration shutdownGracePeriod = Duration.ofSeconds(30);
5353

5454
/**
5555
* Maximum message size allowed to be received by the server (default 4MiB).
5656
*/
5757
@DataSizeUnit(DataUnit.BYTES)
58-
private DataSize maxInboundMessageSize = DataSize.ofBytes(4 * 1024 * 1024);
58+
private DataSize maxInboundMessageSize = DataSize.ofBytes(4194304);
5959

6060
/**
6161
* Maximum metadata size allowed to be received by the server (default 8KiB).
@@ -115,15 +115,15 @@ public static class KeepAlive {
115115
* Duration without read activity before sending a keep alive ping (default 2h).
116116
*/
117117
@DurationUnit(ChronoUnit.SECONDS)
118-
private Duration time = Duration.of(2, ChronoUnit.HOURS);
118+
private Duration time = Duration.ofHours(2);
119119

120120
/**
121121
* Maximum time to wait for read activity after sending a keep alive ping. If
122122
* sender does not receive an acknowledgment within this time, it will close the
123123
* connection (default 20s).
124124
*/
125125
@DurationUnit(ChronoUnit.SECONDS)
126-
private Duration timeout = Duration.of(20, ChronoUnit.SECONDS);
126+
private Duration timeout = Duration.ofSeconds(20);
127127

128128
/**
129129
* Maximum time a connection can remain idle before being gracefully terminated
@@ -149,7 +149,7 @@ public static class KeepAlive {
149149
* Maximum keep-alive time clients are permitted to configure (default 5m).
150150
*/
151151
@DurationUnit(ChronoUnit.SECONDS)
152-
private Duration permitTime = Duration.of(5, ChronoUnit.MINUTES);
152+
private Duration permitTime = Duration.ofMinutes(5);
153153

154154
/**
155155
* Whether clients are permitted to send keep alive pings when there are no

0 commit comments

Comments
 (0)