Skip to content

refactor: use container provided channel registry #153

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 2 commits into from
Aug 2, 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
4 changes: 2 additions & 2 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
if: always()

- name: Publish Unit Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v2
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: ./**/build/test-results/**/*.xml
junit_files: ./**/build/test-results/**/*.xml
2 changes: 1 addition & 1 deletion .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ ignore:
SNYK-JAVA-IONETTY-1042268:
- '*':
reason: No replacement available
expires: 2022-07-31T00:00:00.000Z
expires: 2022-10-31T00:00:00.000Z
patch: {}

1 change: 1 addition & 0 deletions hypertrace-graphql-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies {
api("org.hypertrace.core.graphql:hypertrace-core-graphql-spi")
api("com.graphql-java-kickstart:graphql-java-servlet")
api(project(":hypertrace-graphql-service-config"))
api("org.hypertrace.core.grpcutils:grpc-client-utils")

implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-schema-registry")
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-context")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import graphql.schema.GraphQLSchema;
import org.hypertrace.core.graphql.context.GraphQlRequestContextBuilder;
import org.hypertrace.core.graphql.spi.lifecycle.GraphQlServiceLifecycle;
import org.hypertrace.core.grpcutils.client.GrpcChannelRegistry;
import org.hypertrace.graphql.config.HypertraceGraphQlServiceConfig;

public class GraphQlFactory {
public static GraphQLConfiguration build(
HypertraceGraphQlServiceConfig config, GraphQlServiceLifecycle serviceLifecycle) {
final Injector injector = Guice.createInjector(new GraphQlModule(config, serviceLifecycle));
HypertraceGraphQlServiceConfig config,
GraphQlServiceLifecycle serviceLifecycle,
GrpcChannelRegistry grpcChannelRegistry) {
final Injector injector =
Guice.createInjector(new GraphQlModule(config, serviceLifecycle, grpcChannelRegistry));

return GraphQLConfiguration.with(injector.getInstance(GraphQLSchema.class))
.with(injector.getInstance(GraphQlRequestContextBuilder.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hypertrace.core.graphql.utils.gateway.GatewayUtilsModule;
import org.hypertrace.core.graphql.utils.grpc.GraphQlGrpcModule;
import org.hypertrace.core.graphql.utils.schema.SchemaUtilsModule;
import org.hypertrace.core.grpcutils.client.GrpcChannelRegistry;
import org.hypertrace.graphql.atttribute.scopes.HypertraceAttributeScopeModule;
import org.hypertrace.graphql.config.HypertraceGraphQlServiceConfig;
import org.hypertrace.graphql.entity.EntityIdModule;
Expand All @@ -37,10 +38,15 @@ class GraphQlModule extends AbstractModule {
private final HypertraceGraphQlServiceConfig config;
private final GraphQlServiceLifecycle serviceLifecycle;

private final GrpcChannelRegistry grpcChannelRegistry;

public GraphQlModule(
final HypertraceGraphQlServiceConfig config, final GraphQlServiceLifecycle serviceLifecycle) {
final HypertraceGraphQlServiceConfig config,
final GraphQlServiceLifecycle serviceLifecycle,
final GrpcChannelRegistry grpcChannelRegistry) {
this.config = config;
this.serviceLifecycle = serviceLifecycle;
this.grpcChannelRegistry = grpcChannelRegistry;
}

@Override
Expand All @@ -50,7 +56,7 @@ protected void configure() {
bind(GraphQlServiceLifecycle.class).toInstance(this.serviceLifecycle);
bind(Clock.class).toInstance(Clock.systemUTC());
install(new GraphQlRequestContextModule());
install(new GraphQlGrpcModule());
install(new GraphQlGrpcModule(this.grpcChannelRegistry));
install(new GraphQlSchemaRegistryModule());
install(new GraphQlDeserializationRegistryModule());
install(new HypertraceAttributeScopeModule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.google.inject.Guice;
import org.hypertrace.core.graphql.spi.lifecycle.GraphQlServiceLifecycle;
import org.hypertrace.core.grpcutils.client.GrpcChannelRegistry;
import org.hypertrace.graphql.config.HypertraceGraphQlServiceConfig;
import org.junit.jupiter.api.Test;

Expand All @@ -17,7 +18,8 @@ public void testResolveBindings() {
Guice.createInjector(
new GraphQlModule(
mock(HypertraceGraphQlServiceConfig.class),
mock(GraphQlServiceLifecycle.class)))
mock(GraphQlServiceLifecycle.class),
mock(GrpcChannelRegistry.class)))
.getAllBindings());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public List<HttpHandlerDefinition> buildHandlers(HttpContainerEnvironment enviro
.port(config.getServicePort())
.contextPath(config.getGraphQlUrlPath())
.corsConfig(buildCorsConfig(config))
.servlet(new GraphQlServiceHttpServlet(GraphQlFactory.build(config, serviceLifecycle)))
.servlet(
new GraphQlServiceHttpServlet(
GraphQlFactory.build(
config, serviceLifecycle, environment.getChannelRegistry())))
.build());
}

Expand Down