From 9642e00f7a0fe467502da44c456bfc08599f52cb Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Sun, 6 Oct 2024 13:00:34 -0500 Subject: [PATCH] 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(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. --- spring-grpc-spring-boot-autoconfigure/pom.xml | 6 ++++++ .../autoconfigure/server/GrpcServerProperties.java | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spring-grpc-spring-boot-autoconfigure/pom.xml b/spring-grpc-spring-boot-autoconfigure/pom.xml index 0398ef1..b224b89 100644 --- a/spring-grpc-spring-boot-autoconfigure/pom.xml +++ b/spring-grpc-spring-boot-autoconfigure/pom.xml @@ -22,6 +22,12 @@ + + org.springframework.boot + spring-boot-configuration-processor + true + + com.google.protobuf protobuf-java diff --git a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServerProperties.java b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServerProperties.java index 95b9987..c0d68d5 100644 --- a/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServerProperties.java +++ b/spring-grpc-spring-boot-autoconfigure/src/main/java/org/springframework/grpc/autoconfigure/server/GrpcServerProperties.java @@ -49,13 +49,13 @@ public class GrpcServerProperties { * shutdown immediately. The default is 30 seconds. */ @DurationUnit(ChronoUnit.SECONDS) - private Duration shutdownGracePeriod = Duration.of(30, ChronoUnit.SECONDS); + private Duration shutdownGracePeriod = Duration.ofSeconds(30); /** * Maximum message size allowed to be received by the server (default 4MiB). */ @DataSizeUnit(DataUnit.BYTES) - private DataSize maxInboundMessageSize = DataSize.ofBytes(4 * 1024 * 1024); + private DataSize maxInboundMessageSize = DataSize.ofBytes(4194304); /** * Maximum metadata size allowed to be received by the server (default 8KiB). @@ -115,7 +115,7 @@ public class GrpcServerProperties { * Duration without read activity before sending a keep alive ping (default 2h). */ @DurationUnit(ChronoUnit.SECONDS) - private Duration time = Duration.of(2, ChronoUnit.HOURS); + private Duration time = Duration.ofHours(2); /** * Maximum time to wait for read activity after sending a keep alive ping. If @@ -123,7 +123,7 @@ public class GrpcServerProperties { * connection (default 20s). */ @DurationUnit(ChronoUnit.SECONDS) - private Duration timeout = Duration.of(20, ChronoUnit.SECONDS); + private Duration timeout = Duration.ofSeconds(20); /** * Maximum time a connection can remain idle before being gracefully terminated @@ -149,7 +149,7 @@ public class GrpcServerProperties { * Maximum keep-alive time clients are permitted to configure (default 5m). */ @DurationUnit(ChronoUnit.SECONDS) - private Duration permitTime = Duration.of(5, ChronoUnit.MINUTES); + private Duration permitTime = Duration.ofMinutes(5); /** * Whether clients are permitted to send keep alive pings when there are no