Skip to content

Commit b192634

Browse files
feat: add support for configuring query timeout
1 parent 317440b commit b192634

File tree

7 files changed

+12
-5
lines changed

7 files changed

+12
-5
lines changed

helm/templates/serviceconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ data:
1616
1717
graphql.urlPath = {{ .Values.serviceConfig.urlPath }}
1818
graphql.corsEnabled = {{ .Values.serviceConfig.corsEnabled }}
19+
graphql.timeout = {{ .Values.serviceConfig.timeoutDuration }}
1920
2021
attribute.service = {
2122
host = {{ .Values.serviceConfig.attributeService.host }}

helm/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ serviceConfig:
4646
urlPath: /graphql
4747
corsEnabled: true
4848
defaultTenantId: ""
49+
timeoutDuration: 30s
4950
attributeService:
5051
host: attribute-service
5152
port: 9012

hypertrace-graphql-impl/src/main/java/org/hypertrace/graphql/impl/GraphQlFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static GraphQLConfiguration build(
1515

1616
return GraphQLConfiguration.with(injector.getInstance(GraphQLSchema.class))
1717
.with(injector.getInstance(GraphQlRequestContextBuilder.class))
18+
.asyncTimeout(config.getGraphQlTimeout().toMillis())
1819
.build();
1920
}
2021
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
1717

1818
private static final String GRAPHQL_URL_PATH = "graphql.urlPath";
1919
private static final String GRAPHQL_CORS_ENABLED = "graphql.corsEnabled";
20+
private static final String GRAPHQL_TIMEOUT = "graphql.timeout";
2021

2122
private static final String DEFAULT_TENANT_ID = "defaultTenantId";
2223

@@ -40,8 +41,9 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
4041

4142
String serviceName;
4243
int servicePort;
43-
String graphqlUrlPath;
44+
String graphQlUrlPath;
4445
boolean corsEnabled;
46+
Duration graphQlTimeout;
4547
Optional<String> defaultTenantId;
4648
int maxIoThreads;
4749
String attributeServiceHost;
@@ -60,8 +62,9 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
6062
DefaultGraphQlServiceConfig(Config untypedConfig) {
6163
this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG);
6264
this.servicePort = untypedConfig.getInt(SERVICE_PORT_CONFIG);
63-
this.graphqlUrlPath = untypedConfig.getString(GRAPHQL_URL_PATH);
65+
this.graphQlUrlPath = untypedConfig.getString(GRAPHQL_URL_PATH);
6466
this.corsEnabled = untypedConfig.getBoolean(GRAPHQL_CORS_ENABLED);
67+
this.graphQlTimeout = untypedConfig.getDuration(GRAPHQL_TIMEOUT);
6568
this.defaultTenantId = optionallyGet(() -> untypedConfig.getString(DEFAULT_TENANT_ID));
6669
this.maxIoThreads = untypedConfig.getInt(MAX_IO_THREADS_PROPERTY);
6770

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public GraphQlServiceImpl(Config appConfig) {
2323
if (this.graphQlServiceConfig.isCorsEnabled()) {
2424
contextHandler.addFilter(
2525
CrossOriginFilter.class,
26-
this.graphQlServiceConfig.getGraphqlUrlPath(),
26+
this.graphQlServiceConfig.getGraphQlUrlPath(),
2727
EnumSet.of(DispatcherType.REQUEST));
2828
}
2929

3030
contextHandler.addServlet(
3131
new ServletHolder(
3232
new GraphQlServiceHttpServlet(
3333
GraphQlFactory.build(this.graphQlServiceConfig, this.serviceLifecycle))),
34-
this.graphQlServiceConfig.getGraphqlUrlPath());
34+
this.graphQlServiceConfig.getGraphQlUrlPath());
3535
}
3636

3737
public GraphQlServiceConfig getGraphQlServiceConfig() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ service.admin.port = 23432
55

66
graphql.urlPath = /graphql
77
graphql.corsEnabled = true
8+
graphql.timeout = 30s
89

910
defaultTenantId = ${?DEFAULT_TENANT_ID}
1011

0 commit comments

Comments
 (0)