Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grpc netty keep-alive-time configuration option #14957

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.quarkus.arc.Arc;
import io.quarkus.grpc.runtime.config.GrpcConfiguration;
import io.quarkus.grpc.runtime.config.GrpcServerConfiguration;
import io.quarkus.grpc.runtime.config.GrpcServerNettyConfig;
import io.quarkus.grpc.runtime.devmode.GrpcHotReplacementInterceptor;
import io.quarkus.grpc.runtime.devmode.GrpcServerReloader;
import io.quarkus.grpc.runtime.health.GrpcHealthStorage;
Expand Down Expand Up @@ -192,6 +193,14 @@ public void run() {
});
}

private void applyNettySettings(GrpcServerConfiguration configuration, VertxServerBuilder builder) {
if (configuration.netty != null) {
GrpcServerNettyConfig config = configuration.netty;
config.keepAliveTime.ifPresent(duration -> builder.nettyBuilder()
.keepAliveTime(duration.toNanos(), TimeUnit.NANOSECONDS));
}
}

private void applyTransportSecurityConfig(GrpcServerConfiguration configuration, VertxServerBuilder builder) {
if (configuration.transportSecurity != null) {
File cert = configuration.transportSecurity.certificate
Expand Down Expand Up @@ -302,6 +311,8 @@ public void handle(HttpServerOptions options) {

applyTransportSecurityConfig(configuration, builder);

applyNettySettings(configuration, builder);

boolean reflectionServiceEnabled = configuration.enableReflectionService
|| ProfileManager.getLaunchMode() == LaunchMode.DEVELOPMENT;
List<GrpcServiceDefinition> toBeRegistered = collectServiceDefinitions(grpcContainer.getServices());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ public class GrpcServerConfiguration {
*/
@ConfigItem(defaultValue = "1")
public int instances;

/**
* Configures the netty server settings.
*/
@ConfigItem
public GrpcServerNettyConfig netty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.quarkus.grpc.runtime.config;

import java.time.Duration;
import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
@ConfigGroup
public class GrpcServerNettyConfig {

/**
* Sets a custom keep-alive duration. This configures the time before sending a `keepalive` ping
* when there is no read activity.
*/
@ConfigItem
public Optional<Duration> keepAliveTime;

}