Skip to content
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

Added fetch attribute by id in Attribute Store #171

Merged
merged 2 commits into from
Mar 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface AttributeStore {

Single<AttributeModel> getIdAttribute(GraphQlRequestContext context, String scope);

Single<AttributeModel> getAttributeById(GraphQlRequestContext context, String attributeId);

Single<AttributeModel> getForeignIdAttribute(
GraphQlRequestContext context, String scope, String foreignScope);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@
.flatMap(key -> this.get(context, scope, key));
}

@Override
public Single<AttributeModel> getAttributeById(
GraphQlRequestContext context, String attributeId) {
return grpcContextBuilder
.build(context)
.call(() -> cachingAttributeClient.get(attributeId))
.mapOptional(this.translator::translate)
.switchIfEmpty(Single.error(this.buildErrorForMissingAttributeId(attributeId)));

Check warning on line 96 in hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/CachingAttributeStore.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/CachingAttributeStore.java#L92-L96

Added lines #L92 - L96 were not covered by tests
}

@Override
public Completable create(
final GraphQlRequestContext context, final List<AttributeMetadata> attributes) {
Expand Down Expand Up @@ -139,6 +149,11 @@
String.format("No attribute available for scope '%s' and key '%s'", scope, key));
}

private NoSuchElementException buildErrorForMissingAttributeId(String attributeId) {
return new NoSuchElementException(
String.format("No attribute available for attribute id '%s'", attributeId));

Check warning on line 154 in hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/CachingAttributeStore.java

View check run for this annotation

Codecov / codecov/patch

hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/CachingAttributeStore.java#L153-L154

Added lines #L153 - L154 were not covered by tests
}

private NoSuchElementException buildErrorForMissingForeignScopeMapping(
String scope, String foreignScope) {
return new NoSuchElementException(
Expand Down
Loading