-
Notifications
You must be signed in to change notification settings - Fork 7
Entity Service and Config Service Configurable Timeouts #92
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
502e8c7
Entity service and config service configurable timeouts
suddendust f39ddd9
.synk update expiry date
suddendust 22284e6
Fix typo
suddendust 86bbfe5
Reuse optionallyGet in the implementation of getTimeoutOrFallback
suddendust d009bf9
chore: submodule ref update
suddendust File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule hypertrace-core-graphql
updated
4 files
5 changes: 5 additions & 0 deletions
5
...ce-config/src/main/java/org/hypertrace/graphql/config/HypertraceGraphQlServiceConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package org.hypertrace.graphql.config; | ||
|
||
import java.time.Duration; | ||
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; | ||
|
||
public interface HypertraceGraphQlServiceConfig extends GraphQlServiceConfig { | ||
String getEntityServiceHost(); | ||
|
||
int getEntityServicePort(); | ||
|
||
Duration getEntityServiceTimeout(); | ||
|
||
String getConfigServiceHost(); | ||
|
||
int getConfigServicePort(); | ||
|
||
Duration getConfigServiceTimeout(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
@Value | ||
class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { | ||
|
||
private static final Long DEFAULT_CLIENT_TIMEOUT_SECONDS = 10L; | ||
|
||
private static final String SERVICE_NAME_CONFIG = "service.name"; | ||
private static final String SERVICE_PORT_CONFIG = "service.port"; | ||
|
||
|
@@ -22,16 +24,19 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { | |
|
||
private static final String ATTRIBUTE_SERVICE_HOST_PROPERTY = "attribute.service.host"; | ||
private static final String ATTRIBUTE_SERVICE_PORT_PROPERTY = "attribute.service.port"; | ||
private static final String ATTRIBUTE_SERVICE_CLIENT_TIMEOUT = "attribute.service.timeout"; | ||
|
||
private static final String GATEWAY_SERVICE_HOST_PROPERTY = "gateway.service.host"; | ||
private static final String GATEWAY_SERVICE_PORT_PROPERTY = "gateway.service.port"; | ||
private static final String GATEWAY_SERVICE_CLIENT_TIMEOUT = "gateway.service.timeout"; | ||
|
||
private static final String ENTITY_SERVICE_HOST_PROPERTY = "entity.service.host"; | ||
private static final String ENTITY_SERVICE_PORT_PROPERTY = "entity.service.port"; | ||
private static final String ENTITY_SERVICE_CLIENT_TIMEOUT = "entity.service.timeout"; | ||
|
||
private static final String CONFIG_SERVICE_HOST_PROPERTY = "config.service.host"; | ||
private static final String CONFIG_SERVICE_PORT_PROPERTY = "config.service.port"; | ||
private static final String CONFIG_SERVICE_CLIENT_TIMEOUT = "config.service.timeout"; | ||
|
||
String serviceName; | ||
int servicePort; | ||
|
@@ -41,13 +46,16 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { | |
int maxIoThreads; | ||
String attributeServiceHost; | ||
int attributeServicePort; | ||
Duration attributeServiceTimeout; | ||
String gatewayServiceHost; | ||
int gatewayServicePort; | ||
Duration gatewayServiceTimeout; | ||
String entityServiceHost; | ||
int entityServicePort; | ||
Duration entityServiceTimeout; | ||
String configServiceHost; | ||
int configServicePort; | ||
Duration configServiceTimeout; | ||
|
||
DefaultGraphQlServiceConfig(Config untypedConfig) { | ||
this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG); | ||
|
@@ -65,11 +73,24 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { | |
this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY); | ||
this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY); | ||
this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY); | ||
// fallback timeout: 10s | ||
|
||
this.gatewayServiceTimeout = | ||
untypedConfig.hasPath(GATEWAY_SERVICE_CLIENT_TIMEOUT) | ||
? untypedConfig.getDuration(GATEWAY_SERVICE_CLIENT_TIMEOUT) | ||
: Duration.ofSeconds(10); | ||
getSuppliedDurationOrFallback( | ||
() -> untypedConfig.getDuration(GATEWAY_SERVICE_CLIENT_TIMEOUT)); | ||
this.attributeServiceTimeout = | ||
getSuppliedDurationOrFallback( | ||
() -> untypedConfig.getDuration(ATTRIBUTE_SERVICE_CLIENT_TIMEOUT)); | ||
this.configServiceTimeout = | ||
getSuppliedDurationOrFallback( | ||
() -> untypedConfig.getDuration(CONFIG_SERVICE_CLIENT_TIMEOUT)); | ||
this.entityServiceTimeout = | ||
getSuppliedDurationOrFallback( | ||
() -> untypedConfig.getDuration(ENTITY_SERVICE_CLIENT_TIMEOUT)); | ||
} | ||
|
||
private Duration getSuppliedDurationOrFallback(Supplier<Duration> durationSupplier) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same nit about using optionallyGet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed. Thanks :) |
||
return optionallyGet(durationSupplier) | ||
.orElse(Duration.ofSeconds(DEFAULT_CLIENT_TIMEOUT_SECONDS)); | ||
} | ||
|
||
private <T> Optional<T> optionallyGet(Supplier<T> valueSupplier) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this use anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entityServiceTimeout is not being used anywhere.
EntityTypeCachingClient
uses a hardcoded value of 10s here. Should this value be replaced with this timeout?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was checking at the GQL level, if it is not used, should we add it or should we add it when it is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's a fair point. I just added it so that we have a consistent configuration (as all other services had a timeout). Should I remove it (we do have a default fallback value though so even if you don't give the config it'll work).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep it for consistency as we are going with the different services that might have a different timeout requirement, and already have fields for (host, port) for this one.