-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing graphql apis for label application rules (#108)
* Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Implementing graphql apis for label application rules * Fixing small bug * Simplifying schema * Addessing PR comments * Addessing PR comments * Addressing PR comments * Addressing PR comments * Upgrade hypertrace-core-graphql from origin/main Co-authored-by: kamaleshnneerasa <[email protected]> Co-authored-by: saxenakshitiz <[email protected]>
- Loading branch information
1 parent
ed9fa50
commit 597ad5f
Showing
38 changed files
with
1,669 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
hypertrace-graphql-label-application-rules-schema/build.gradle.kts
This file contains 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
plugins { | ||
`java-library` | ||
jacoco | ||
id("org.hypertrace.jacoco-report-plugin") | ||
} | ||
|
||
dependencies { | ||
api("com.google.inject:guice") | ||
api("com.graphql-java:graphql-java") | ||
api("org.hypertrace.core.graphql:hypertrace-core-graphql-spi") | ||
api("io.github.graphql-java:graphql-java-annotations") | ||
api("org.hypertrace.core.graphql:hypertrace-core-graphql-common-schema") | ||
|
||
annotationProcessor("org.projectlombok:lombok") | ||
compileOnly("org.projectlombok:lombok") | ||
|
||
implementation("org.slf4j:slf4j-api") | ||
implementation("io.reactivex.rxjava3:rxjava") | ||
implementation("org.hypertrace.config.service:label-application-rule-config-service-api") | ||
implementation("com.google.protobuf:protobuf-java-util") | ||
implementation("com.google.guava:guava") | ||
|
||
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-context") | ||
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-grpc-utils") | ||
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-schema-utils") | ||
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-rx-utils") | ||
implementation("org.hypertrace.core.graphql:hypertrace-core-graphql-deserialization") | ||
|
||
implementation(project(":hypertrace-graphql-service-config")) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/org/hypertrace/graphql/label/application/rules/LabelApplicationRuleSchemaFragment.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.hypertrace.graphql.label.application.rules; | ||
|
||
import org.hypertrace.core.graphql.spi.schema.GraphQlSchemaFragment; | ||
import org.hypertrace.graphql.label.application.rules.schema.mutation.LabelApplicationRuleMutationSchema; | ||
import org.hypertrace.graphql.label.application.rules.schema.query.LabelApplicationRuleQuerySchema; | ||
|
||
public class LabelApplicationRuleSchemaFragment implements GraphQlSchemaFragment { | ||
|
||
@Override | ||
public String fragmentName() { | ||
return "Label Application Rules Schema"; | ||
} | ||
|
||
@Override | ||
public Class<LabelApplicationRuleQuerySchema> annotatedQueryClass() { | ||
return LabelApplicationRuleQuerySchema.class; | ||
} | ||
|
||
@Override | ||
public Class<?> annotatedMutationClass() { | ||
return LabelApplicationRuleMutationSchema.class; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...java/org/hypertrace/graphql/label/application/rules/LabelApplicationRuleSchemaModule.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.hypertrace.graphql.label.application.rules; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.multibindings.Multibinder; | ||
import org.hypertrace.core.graphql.spi.schema.GraphQlSchemaFragment; | ||
import org.hypertrace.graphql.label.application.rules.dao.LabelApplicationRuleDaoModule; | ||
import org.hypertrace.graphql.label.application.rules.deserialization.LabelApplicationRuleDeserializationModule; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleRequestModule; | ||
|
||
public class LabelApplicationRuleSchemaModule extends AbstractModule { | ||
@Override | ||
protected void configure() { | ||
Multibinder.newSetBinder(binder(), GraphQlSchemaFragment.class) | ||
.addBinding() | ||
.to(LabelApplicationRuleSchemaFragment.class); | ||
|
||
install(new LabelApplicationRuleDaoModule()); | ||
install(new LabelApplicationRuleRequestModule()); | ||
install(new LabelApplicationRuleDeserializationModule()); | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
.../hypertrace/graphql/label/application/rules/dao/LabelApplicationRuleConfigServiceDao.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package org.hypertrace.graphql.label.application.rules.dao; | ||
|
||
import io.grpc.CallCredentials; | ||
import io.reactivex.rxjava3.core.Single; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.inject.Inject; | ||
import org.hypertrace.core.graphql.common.request.ContextualRequest; | ||
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry; | ||
import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder; | ||
import org.hypertrace.graphql.config.HypertraceGraphQlServiceConfig; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleCreateRequest; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleDeleteRequest; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleUpdateRequest; | ||
import org.hypertrace.graphql.label.application.rules.schema.query.LabelApplicationRuleResultSet; | ||
import org.hypertrace.graphql.label.application.rules.schema.shared.LabelApplicationRule; | ||
import org.hypertrace.label.application.rule.config.service.v1.GetLabelApplicationRulesRequest; | ||
import org.hypertrace.label.application.rule.config.service.v1.LabelApplicationRuleConfigServiceGrpc; | ||
import org.hypertrace.label.application.rule.config.service.v1.LabelApplicationRuleConfigServiceGrpc.LabelApplicationRuleConfigServiceFutureStub; | ||
|
||
class LabelApplicationRuleConfigServiceDao implements LabelApplicationRuleDao { | ||
|
||
private final LabelApplicationRuleConfigServiceFutureStub | ||
labelApplicationRuleConfigServiceFutureStub; | ||
private final GrpcContextBuilder grpcContextBuilder; | ||
private final HypertraceGraphQlServiceConfig serviceConfig; | ||
private final LabelApplicationRuleRequestConverter requestConverter; | ||
private final LabelApplicationRuleResponseConverter responseConverter; | ||
|
||
@Inject | ||
LabelApplicationRuleConfigServiceDao( | ||
HypertraceGraphQlServiceConfig serviceConfig, | ||
CallCredentials credentials, | ||
GrpcContextBuilder grpcContextBuilder, | ||
GrpcChannelRegistry grpcChannelRegistry, | ||
LabelApplicationRuleRequestConverter requestConverter, | ||
LabelApplicationRuleResponseConverter responseConverter) { | ||
this.grpcContextBuilder = grpcContextBuilder; | ||
this.serviceConfig = serviceConfig; | ||
this.requestConverter = requestConverter; | ||
this.responseConverter = responseConverter; | ||
this.labelApplicationRuleConfigServiceFutureStub = | ||
LabelApplicationRuleConfigServiceGrpc.newFutureStub( | ||
grpcChannelRegistry.forAddress( | ||
serviceConfig.getConfigServiceHost(), serviceConfig.getConfigServicePort())) | ||
.withCallCredentials(credentials); | ||
} | ||
|
||
@Override | ||
public Single<LabelApplicationRule> createLabelApplicationRule( | ||
LabelApplicationRuleCreateRequest request) { | ||
return Single.fromFuture( | ||
this.grpcContextBuilder | ||
.build(request.context()) | ||
.call( | ||
() -> | ||
this.labelApplicationRuleConfigServiceFutureStub | ||
.withDeadlineAfter( | ||
serviceConfig.getConfigServiceTimeout().toMillis(), | ||
TimeUnit.MILLISECONDS) | ||
.createLabelApplicationRule( | ||
this.requestConverter.convertCreationRequest(request)))) | ||
.flatMap(this.responseConverter::convertCreateLabelApplicationRuleResponse); | ||
} | ||
|
||
@Override | ||
public Single<LabelApplicationRuleResultSet> getLabelApplicationRules(ContextualRequest request) { | ||
return Single.fromFuture( | ||
this.grpcContextBuilder | ||
.build(request.context()) | ||
.call( | ||
() -> | ||
this.labelApplicationRuleConfigServiceFutureStub | ||
.withDeadlineAfter( | ||
serviceConfig.getConfigServiceTimeout().toMillis(), | ||
TimeUnit.MILLISECONDS) | ||
.getLabelApplicationRules( | ||
GetLabelApplicationRulesRequest.getDefaultInstance()))) | ||
.flatMap(this.responseConverter::convertGetLabelApplicationsRuleResponse); | ||
} | ||
|
||
@Override | ||
public Single<LabelApplicationRule> updateLabelApplicationRule( | ||
LabelApplicationRuleUpdateRequest request) { | ||
return Single.fromFuture( | ||
this.grpcContextBuilder | ||
.build(request.context()) | ||
.call( | ||
() -> | ||
this.labelApplicationRuleConfigServiceFutureStub | ||
.withDeadlineAfter( | ||
serviceConfig.getConfigServiceTimeout().toMillis(), | ||
TimeUnit.MILLISECONDS) | ||
.updateLabelApplicationRule( | ||
this.requestConverter.convertUpdateRequest(request)))) | ||
.flatMap(this.responseConverter::convertUpdateLabelApplicationRuleResponse); | ||
} | ||
|
||
@Override | ||
public Single<Boolean> deleteLabelApplicationRule(LabelApplicationRuleDeleteRequest request) { | ||
return Single.fromFuture( | ||
this.grpcContextBuilder | ||
.build(request.context()) | ||
.call( | ||
() -> | ||
this.labelApplicationRuleConfigServiceFutureStub | ||
.withDeadlineAfter( | ||
serviceConfig.getConfigServiceTimeout().toMillis(), | ||
TimeUnit.MILLISECONDS) | ||
.deleteLabelApplicationRule( | ||
this.requestConverter.convertDeleteRequest(request)))) | ||
.flatMap( | ||
unusedResponse -> this.responseConverter.buildDeleteLabelApplicationRuleResponse()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...main/java/org/hypertrace/graphql/label/application/rules/dao/LabelApplicationRuleDao.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.hypertrace.graphql.label.application.rules.dao; | ||
|
||
import io.reactivex.rxjava3.core.Single; | ||
import org.hypertrace.core.graphql.common.request.ContextualRequest; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleCreateRequest; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleDeleteRequest; | ||
import org.hypertrace.graphql.label.application.rules.request.LabelApplicationRuleUpdateRequest; | ||
import org.hypertrace.graphql.label.application.rules.schema.query.LabelApplicationRuleResultSet; | ||
import org.hypertrace.graphql.label.application.rules.schema.shared.LabelApplicationRule; | ||
|
||
public interface LabelApplicationRuleDao { | ||
Single<LabelApplicationRule> createLabelApplicationRule( | ||
LabelApplicationRuleCreateRequest request); | ||
|
||
Single<LabelApplicationRuleResultSet> getLabelApplicationRules(ContextualRequest request); | ||
|
||
Single<LabelApplicationRule> updateLabelApplicationRule( | ||
LabelApplicationRuleUpdateRequest request); | ||
|
||
Single<Boolean> deleteLabelApplicationRule(LabelApplicationRuleDeleteRequest request); | ||
} |
18 changes: 18 additions & 0 deletions
18
...ava/org/hypertrace/graphql/label/application/rules/dao/LabelApplicationRuleDaoModule.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.hypertrace.graphql.label.application.rules.dao; | ||
|
||
import com.google.inject.AbstractModule; | ||
import io.grpc.CallCredentials; | ||
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; | ||
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry; | ||
import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder; | ||
|
||
public class LabelApplicationRuleDaoModule extends AbstractModule { | ||
@Override | ||
protected void configure() { | ||
bind(LabelApplicationRuleDao.class).to(LabelApplicationRuleConfigServiceDao.class); | ||
requireBinding(CallCredentials.class); | ||
requireBinding(GraphQlServiceConfig.class); | ||
requireBinding(GrpcChannelRegistry.class); | ||
requireBinding(GrpcContextBuilder.class); | ||
} | ||
} |
Oops, something went wrong.