Skip to content

Commit a73c7df

Browse files
committed
Adjust docs: Use any negative value for infinite timeout + channel impl
1 parent 62b1c82 commit a73c7df

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/channelfactory/AbstractChannelFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ private static class ShutdownRecord {
357357
public ShutdownRecord(final String name, final ManagedChannel channel, final long gracePeriod) {
358358
this.name = name;
359359
this.channel = channel;
360-
this.gracePeriod = gracePeriod;
360+
// gracePeriod < 0 => Infinite
361+
this.gracePeriod = gracePeriod < 0 ? Long.MAX_VALUE : gracePeriod;
361362
}
362363

363364
long getGracePeriod() {

grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/config/GrpcChannelProperties.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ public void setKeepAliveWithoutCalls(final Boolean keepAliveWithoutCalls) {
270270
private static final Duration DEFAULT_SHUTDOWN_GRACE_PERIOD = Duration.ofSeconds(30);
271271

272272
/**
273-
* Gets the time to wait for the channel to gracefully shutdown. If set to {@code -1} the server waits forever. If
274-
* set to {@code 0} the server will force shutdown immediately. Defaults to {@code 30s}.
273+
* Gets the time to wait for the channel to gracefully shutdown. If set to a negative value, the channel waits
274+
* forever. If set to {@code 0} the channel will force shutdown immediately. Defaults to {@code 30s}.
275275
*
276276
* @return The time to wait for a graceful shutdown.
277277
*/
@@ -280,8 +280,9 @@ public Duration getShutdownGracePeriod() {
280280
}
281281

282282
/**
283-
* Sets the time to wait for the channel to gracefully shutdown (completing all requests). If set to {@code -1} the
284-
* channel waits forever. If set to {@code 0} the channel will force shutdown immediately. Defaults to {@code 30s}.
283+
* Sets the time to wait for the channel to gracefully shutdown (completing all requests). If set to a negative
284+
* value, the channel waits forever. If set to {@code 0} the channel will force shutdown immediately. Defaults to
285+
* {@code 30s}.
285286
*
286287
* @param shutdownGracePeriod The time to wait for a graceful shutdown.
287288
*/
@@ -458,6 +459,9 @@ public void copyDefaultsFrom(final GrpcChannelProperties config) {
458459
if (this.keepAliveWithoutCalls == null) {
459460
this.keepAliveWithoutCalls = config.keepAliveWithoutCalls;
460461
}
462+
if (this.shutdownGracePeriod == null) {
463+
this.shutdownGracePeriod = config.shutdownGracePeriod;
464+
}
461465
if (this.maxInboundMessageSize == null) {
462466
this.maxInboundMessageSize = config.maxInboundMessageSize;
463467
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public class GrpcServerProperties {
9595

9696
/**
9797
* The time to wait for the server to gracefully shutdown (completing all requests after the server started to
98-
* shutdown). If set to {@code -1} the server waits forever. If set to {@code 0} the server will force shutdown
99-
* immediately. Defaults to {@code 30s}.
98+
* shutdown). If set to a negative value, the server waits forever. If set to {@code 0} the server will force
99+
* shutdown immediately. Defaults to {@code 30s}.
100100
*
101101
* @param gracefullShutdownTimeout The time to wait for a graceful shutdown.
102102
* @return The time to wait for a graceful shutdown.

0 commit comments

Comments
 (0)