From 87b1235780e8aee7b6ea5f63af1d71e7beb2bc5d Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Tue, 14 Apr 2026 10:56:09 +0530 Subject: [PATCH 1/2] Add optional maxConnectionAge and maxConnectionAgeGrace support to GrpcPlatformServerDefinition AI-Session-Id: c5dae67b-13fb-4369-80af-7b15a26bfbdf AI-Tool: claude-code AI-Model: unknown --- .../serviceframework/grpc/GrpcPlatformServerDefinition.java | 2 ++ .../serviceframework/grpc/GrpcPlatformServiceContainer.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java index 5b77dda..5e14baf 100644 --- a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java +++ b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java @@ -17,6 +17,8 @@ public class GrpcPlatformServerDefinition { int port; int maxInboundMessageSize; @Builder.Default int maxRstPerMinute = 500; + @Builder.Default long maxConnectionAgeInSeconds = 0; + @Builder.Default long maxConnectionAgeGraceInSeconds = 0; @Singular Collection serviceFactories; @Singular List serverInterceptors; } diff --git a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java index f098a5a..200854d 100644 --- a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java +++ b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java @@ -286,6 +286,12 @@ private ServerBuilder initializeBuilder(GrpcPlatformServerDefinition serverDe if (serverDefinition.getMaxRstPerMinute() > 0) { builder.maxRstFramesPerWindow(serverDefinition.getMaxRstPerMinute(), 60); } + if (serverDefinition.getMaxConnectionAgeInSeconds() > 0) { + builder.maxConnectionAge(serverDefinition.getMaxConnectionAgeInSeconds(), SECONDS); + } + if (serverDefinition.getMaxConnectionAgeGraceInSeconds() > 0) { + builder.maxConnectionAgeGrace(serverDefinition.getMaxConnectionAgeGraceInSeconds(), SECONDS); + } // add micrometer-grpc interceptor to collect server metrics. builder.intercept( new MetricCollectingServerInterceptor( From 16242c68cd87437ccaeeae6df8aae9a3272041e0 Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Wed, 15 Apr 2026 00:57:52 +0530 Subject: [PATCH 2/2] Change maxConnectionAge fields from seconds to Duration --- .../grpc/GrpcPlatformServerDefinition.java | 5 +++-- .../grpc/GrpcPlatformServiceContainer.java | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java index 5e14baf..37e8946 100644 --- a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java +++ b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServerDefinition.java @@ -1,6 +1,7 @@ package org.hypertrace.core.serviceframework.grpc; import io.grpc.ServerInterceptor; +import java.time.Duration; import java.util.Collection; import java.util.List; import lombok.AccessLevel; @@ -17,8 +18,8 @@ public class GrpcPlatformServerDefinition { int port; int maxInboundMessageSize; @Builder.Default int maxRstPerMinute = 500; - @Builder.Default long maxConnectionAgeInSeconds = 0; - @Builder.Default long maxConnectionAgeGraceInSeconds = 0; + @Builder.Default Duration maxConnectionAge = Duration.ZERO; + @Builder.Default Duration maxConnectionAgeGrace = Duration.ZERO; @Singular Collection serviceFactories; @Singular List serverInterceptors; } diff --git a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java index 200854d..435ea0f 100644 --- a/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java +++ b/platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java @@ -286,11 +286,12 @@ private ServerBuilder initializeBuilder(GrpcPlatformServerDefinition serverDe if (serverDefinition.getMaxRstPerMinute() > 0) { builder.maxRstFramesPerWindow(serverDefinition.getMaxRstPerMinute(), 60); } - if (serverDefinition.getMaxConnectionAgeInSeconds() > 0) { - builder.maxConnectionAge(serverDefinition.getMaxConnectionAgeInSeconds(), SECONDS); + if (!serverDefinition.getMaxConnectionAge().isZero()) { + builder.maxConnectionAge(serverDefinition.getMaxConnectionAge().toMillis(), MILLISECONDS); } - if (serverDefinition.getMaxConnectionAgeGraceInSeconds() > 0) { - builder.maxConnectionAgeGrace(serverDefinition.getMaxConnectionAgeGraceInSeconds(), SECONDS); + if (!serverDefinition.getMaxConnectionAgeGrace().isZero()) { + builder.maxConnectionAgeGrace( + serverDefinition.getMaxConnectionAgeGrace().toMillis(), MILLISECONDS); } // add micrometer-grpc interceptor to collect server metrics. builder.intercept(