Skip to content

Gateway-Service Client Timeout Config #91

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
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GatewayBaselineDao implements BaselineDao {
private final Converter<Collection<MetricAggregationRequest>, Set<Expression>>
aggregationConverter;
private final Converter<Collection<MetricSeriesRequest>, Set<TimeAggregation>> seriesConverter;
private final GraphQlServiceConfig serviceConfig;

@Inject
GatewayBaselineDao(
Expand All @@ -52,11 +53,12 @@ class GatewayBaselineDao implements BaselineDao {
this.grpcContextBuilder = grpcContextBuilder;
this.gatewayServiceStub =
GatewayServiceGrpc.newFutureStub(
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
.withCallCredentials(credentials);
this.seriesConverter = seriesConverter;
this.aggregationConverter = aggregationConverter;
this.serviceConfig = serviceConfig;
}

@Override
Expand Down Expand Up @@ -127,7 +129,8 @@ private Single<BaselineEntitiesResponse> makeRequest(
.callInContext(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(),
SECONDS)
.getBaselineForEntities(request)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

@Singleton
class GatewayServiceEntityDao implements EntityDao {
private static final int DEFAULT_DEADLINE_SEC = 10;
private final GatewayServiceFutureStub gatewayServiceStub;
private final GraphQlGrpcContextBuilder grpcContextBuilder;
private final GatewayServiceEntityRequestBuilder requestBuilder;
private final GatewayServiceEntityConverter entityConverter;
private final BaselineDao baselineDao;
private final GraphQlServiceConfig serviceConfig;

@Inject
GatewayServiceEntityDao(
Expand All @@ -40,11 +40,12 @@ class GatewayServiceEntityDao implements EntityDao {
this.requestBuilder = requestBuilder;
this.entityConverter = entityConverter;
this.baselineDao = baselineDao;
this.serviceConfig = serviceConfig;

this.gatewayServiceStub =
GatewayServiceGrpc.newFutureStub(
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
.withCallCredentials(credentials);
}

Expand Down Expand Up @@ -77,7 +78,8 @@ private Single<EntitiesResponse> makeRequest(
.callInContext(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(),
SECONDS)
.getEntities(request)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

@Singleton
class GatewayServiceExplorerDao implements ExplorerDao {
private static final int DEFAULT_DEADLINE_SEC = 10;
private final GatewayServiceFutureStub gatewayServiceStub;
private final GraphQlGrpcContextBuilder grpcContextBuilder;
private final GatewayServiceExploreRequestBuilder requestBuilder;
private final GatewayServiceExploreResponseConverter responseConverter;
private final GraphQlServiceConfig serviceConfig;

@Inject
GatewayServiceExplorerDao(
Expand All @@ -35,11 +35,12 @@ class GatewayServiceExplorerDao implements ExplorerDao {
this.grpcContextBuilder = grpcContextBuilder;
this.requestBuilder = requestBuilder;
this.responseConverter = responseConverter;
this.serviceConfig = serviceConfig;

this.gatewayServiceStub =
GatewayServiceGrpc.newFutureStub(
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
grpcChannelRegistry.forAddress(
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
.withCallCredentials(credentials);
}

Expand All @@ -60,7 +61,8 @@ private Single<ExploreResponse> makeRequest(
.callInContext(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(),
SECONDS)
.explore(request)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {

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_RPC_CLIENT_DEADLINE = "gateway.service.deadline";

private static final String ENTITY_SERVICE_HOST_PROPERTY = "entity.service.host";
private static final String ENTITY_SERVICE_PORT_PROPERTY = "entity.service.port";
Expand All @@ -41,6 +42,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig {
int attributeServicePort;
String gatewayServiceHost;
int gatewayServicePort;
int gatewayServiceRPCClientDeadline;
String entityServiceHost;
int entityServicePort;
String configServiceHost;
Expand All @@ -62,6 +64,7 @@ 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);
this.gatewayServiceRPCClientDeadline = untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE);
}

private <T> Optional<T> optionallyGet(Supplier<T> valueSupplier) {
Expand Down