Skip to content

feat: add support for configuring query timeout #129

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

Merged
merged 1 commit into from
Jan 27, 2022
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
1 change: 1 addition & 0 deletions helm/templates/serviceconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data:

graphql.urlPath = {{ .Values.serviceConfig.urlPath }}
graphql.corsEnabled = {{ .Values.serviceConfig.corsEnabled }}
graphql.timeout = {{ .Values.serviceConfig.timeoutDuration }}

attribute.service = {
host = {{ .Values.serviceConfig.attributeService.host }}
Expand Down
1 change: 1 addition & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ serviceConfig:
urlPath: /graphql
corsEnabled: true
defaultTenantId: ""
timeoutDuration: 30s
attributeService:
host: attribute-service
port: 9012
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static GraphQLConfiguration build(

return GraphQLConfiguration.with(injector.getInstance(GraphQLSchema.class))
.with(injector.getInstance(GraphQlRequestContextBuilder.class))
.asyncTimeout(config.getGraphQlTimeout().toMillis())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {

private static final String GRAPHQL_URL_PATH = "graphql.urlPath";
private static final String GRAPHQL_CORS_ENABLED = "graphql.corsEnabled";
private static final String GRAPHQL_TIMEOUT = "graphql.timeout";

private static final String DEFAULT_TENANT_ID = "defaultTenantId";

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

String serviceName;
int servicePort;
String graphqlUrlPath;
String graphQlUrlPath;
boolean corsEnabled;
Duration graphQlTimeout;
Optional<String> defaultTenantId;
int maxIoThreads;
String attributeServiceHost;
Expand All @@ -60,8 +62,9 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
DefaultGraphQlServiceConfig(Config untypedConfig) {
this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG);
this.servicePort = untypedConfig.getInt(SERVICE_PORT_CONFIG);
this.graphqlUrlPath = untypedConfig.getString(GRAPHQL_URL_PATH);
this.graphQlUrlPath = untypedConfig.getString(GRAPHQL_URL_PATH);
this.corsEnabled = untypedConfig.getBoolean(GRAPHQL_CORS_ENABLED);
this.graphQlTimeout = untypedConfig.getDuration(GRAPHQL_TIMEOUT);
this.defaultTenantId = optionallyGet(() -> untypedConfig.getString(DEFAULT_TENANT_ID));
this.maxIoThreads = untypedConfig.getInt(MAX_IO_THREADS_PROPERTY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public GraphQlServiceImpl(Config appConfig) {
if (this.graphQlServiceConfig.isCorsEnabled()) {
contextHandler.addFilter(
CrossOriginFilter.class,
this.graphQlServiceConfig.getGraphqlUrlPath(),
this.graphQlServiceConfig.getGraphQlUrlPath(),
EnumSet.of(DispatcherType.REQUEST));
}

contextHandler.addServlet(
new ServletHolder(
new GraphQlServiceHttpServlet(
GraphQlFactory.build(this.graphQlServiceConfig, this.serviceLifecycle))),
this.graphQlServiceConfig.getGraphqlUrlPath());
this.graphQlServiceConfig.getGraphQlUrlPath());
}

public GraphQlServiceConfig getGraphQlServiceConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ service.admin.port = 23432

graphql.urlPath = /graphql
graphql.corsEnabled = true
graphql.timeout = 30s

defaultTenantId = ${?DEFAULT_TENANT_ID}

Expand Down