-
Notifications
You must be signed in to change notification settings - Fork 7
Implementing graphql apis for label application rules #108
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
16 commits
Select commit
Hold shift + click to select a range
7c3a1f7
Implementing graphql apis for label application rules
61e5417
Implementing graphql apis for label application rules
d357ce3
Implementing graphql apis for label application rules
ec9bcc9
Implementing graphql apis for label application rules
f1c2541
Implementing graphql apis for label application rules
6ed7e63
Implementing graphql apis for label application rules
3d132cd
Implementing graphql apis for label application rules
51d5e06
Implementing graphql apis for label application rules
932f27c
Fixing small bug
6a56adb
Simplifying schema
459a664
Addessing PR comments
250e698
Addessing PR comments
7e606d8
Addressing PR comments
d227623
Addressing PR comments
6e1b4d3
Addressing PR comments
47be40c
Upgrade hypertrace-core-graphql from origin/main
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
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
34 changes: 34 additions & 0 deletions
34
hypertrace-graphql-label-application-rules-schema/build.gradle.kts
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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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 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 |
---|---|---|
@@ -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); | ||
kamaleshnneerasa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
requireBinding(GraphQlServiceConfig.class); | ||
requireBinding(GrpcChannelRegistry.class); | ||
requireBinding(GrpcContextBuilder.class); | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.