Skip to content

Commit dc8d1d5

Browse files
authored
chore(gateway-service): configurable max channel inbound message size (#193)
* chore(gateway-service): configurable max channel inbound message size * upgrade submodule * club configs
1 parent 6f93c2e commit dc8d1d5

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

hypertrace-graphql-entity-schema/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ dependencies {
2929
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-deserialization")
3030
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-rx-utils")
3131

32+
implementation("org.hypertrace.core.grpcutils:grpc-client-utils")
33+
3234
implementation(project(":hypertrace-graphql-labels-schema-api"))
3335

3436
testImplementation("org.junit.jupiter:junit-jupiter")

hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
1818
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
1919
import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder;
20+
import org.hypertrace.core.grpcutils.client.GrpcChannelConfig;
2021
import org.hypertrace.gateway.service.GatewayServiceGrpc;
2122
import org.hypertrace.gateway.service.GatewayServiceGrpc.GatewayServiceFutureStub;
2223
import org.hypertrace.gateway.service.v1.common.Value;
@@ -63,10 +64,17 @@ class GatewayServiceEntityDao implements EntityDao {
6364
this.serviceConfig = serviceConfig;
6465
this.boundedIoScheduler = boundedIoScheduler;
6566

67+
final GrpcChannelConfig grpcChannelConfig =
68+
GrpcChannelConfig.builder()
69+
.maxInboundMessageSize(serviceConfig.getGatewayServiceMaxInboundMessageSize())
70+
.build();
71+
6672
this.gatewayServiceStub =
6773
GatewayServiceGrpc.newFutureStub(
6874
grpcChannelRegistry.forAddress(
69-
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
75+
serviceConfig.getGatewayServiceHost(),
76+
serviceConfig.getGatewayServicePort(),
77+
grpcChannelConfig))
7078
.withCallCredentials(credentials);
7179
}
7280

hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
3131
private static final String GATEWAY_SERVICE_HOST_PROPERTY = "gateway.service.host";
3232
private static final String GATEWAY_SERVICE_PORT_PROPERTY = "gateway.service.port";
3333
private static final String GATEWAY_SERVICE_CLIENT_TIMEOUT = "gateway.service.timeout";
34+
private static final String GATEWAY_SERVICE_CLIENT_MAX_INBOUND_MESSAGE_SIZE =
35+
"gateway.service.maxMessageSize.inbound";
3436

3537
private static final String ENTITY_SERVICE_HOST_PROPERTY = "entity.service.host";
3638
private static final String ENTITY_SERVICE_PORT_PROPERTY = "entity.service.port";
@@ -54,6 +56,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
5456
String gatewayServiceHost;
5557
int gatewayServicePort;
5658
Duration gatewayServiceTimeout;
59+
int gatewayServiceMaxInboundMessageSize;
5760
String entityServiceHost;
5861
int entityServicePort;
5962
Duration entityServiceTimeout;
@@ -73,25 +76,29 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
7376

7477
this.attributeServiceHost = untypedConfig.getString(ATTRIBUTE_SERVICE_HOST_PROPERTY);
7578
this.attributeServicePort = untypedConfig.getInt(ATTRIBUTE_SERVICE_PORT_PROPERTY);
79+
this.attributeServiceTimeout =
80+
getSuppliedDurationOrFallback(
81+
() -> untypedConfig.getDuration(ATTRIBUTE_SERVICE_CLIENT_TIMEOUT));
82+
7683
this.gatewayServiceHost = untypedConfig.getString(GATEWAY_SERVICE_HOST_PROPERTY);
7784
this.gatewayServicePort = untypedConfig.getInt(GATEWAY_SERVICE_PORT_PROPERTY);
78-
this.entityServiceHost = untypedConfig.getString(ENTITY_SERVICE_HOST_PROPERTY);
79-
this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY);
80-
this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY);
81-
this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY);
82-
8385
this.gatewayServiceTimeout =
8486
getSuppliedDurationOrFallback(
8587
() -> untypedConfig.getDuration(GATEWAY_SERVICE_CLIENT_TIMEOUT));
86-
this.attributeServiceTimeout =
88+
this.gatewayServiceMaxInboundMessageSize =
89+
untypedConfig.getBytes(GATEWAY_SERVICE_CLIENT_MAX_INBOUND_MESSAGE_SIZE).intValue();
90+
91+
this.entityServiceHost = untypedConfig.getString(ENTITY_SERVICE_HOST_PROPERTY);
92+
this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY);
93+
this.entityServiceTimeout =
8794
getSuppliedDurationOrFallback(
88-
() -> untypedConfig.getDuration(ATTRIBUTE_SERVICE_CLIENT_TIMEOUT));
95+
() -> untypedConfig.getDuration(ENTITY_SERVICE_CLIENT_TIMEOUT));
96+
97+
this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY);
98+
this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY);
8999
this.configServiceTimeout =
90100
getSuppliedDurationOrFallback(
91101
() -> untypedConfig.getDuration(CONFIG_SERVICE_CLIENT_TIMEOUT));
92-
this.entityServiceTimeout =
93-
getSuppliedDurationOrFallback(
94-
() -> untypedConfig.getDuration(ENTITY_SERVICE_CLIENT_TIMEOUT));
95102
}
96103

97104
private Duration getSuppliedDurationOrFallback(Supplier<Duration> durationSupplier) {

hypertrace-graphql-service/src/main/resources/configs/common/application.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ gateway.service = {
2424
host = ${?GATEWAY_SERVICE_HOST_CONFIG}
2525
port = 50071
2626
port = ${?GATEWAY_SERVICE_PORT_CONFIG}
27+
maxMessageSize = {
28+
inbound = 4MiB
29+
inbound = ${?GATEWAY_SERVICE_MAX_INBOUND_MESSAGE_SIZE_CONFIG}
30+
}
2731
}
2832

2933
entity.service = {

0 commit comments

Comments
 (0)