Skip to content

Commit

Permalink
fix: Remove extra logic to convert to project numbers now that this i…
Browse files Browse the repository at this point in the history
…s handled in the backend (#397)

* fix: Remove extra logic to convert to project numbers now that this is handled in the backend

* fix: Remove extra logic to convert to project numbers now that this is handled in the backend

* fix: update differences file
  • Loading branch information
dpcollins-google committed Dec 4, 2020
1 parent 0e4cb93 commit 14e5ab4
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 197 deletions.
41 changes: 2 additions & 39 deletions google-cloud-pubsublite/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<differences>
<!-- GAPIC conversion: remove on next release. -->
<difference>
<differenceType>6001</differenceType>
<className>com/google/cloud/pubsublite/ErrorCodes</className>
<field>*</field>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/pubsublite/ErrorCodes</className>
<method>*</method>
</difference>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/pubsublite/ErrorCodes</className>
<method>*</method>
<to>*</to>
</difference>
<!-- Removed not needed API -->
<difference>
<differenceType>8001</differenceType>
<className>com/google/cloud/pubsublite/Stubs</className>
<method>*</method>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/pubsublite/*Settings*</className>
<method>*</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/pubsublite/*Settings*</className>
<method>*</method>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/*Settings*</className>
<method>*</method>
</difference>
<difference>
<differenceType>7013</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/*Settings*</className>
<method>*</method>
<className>com/google/cloud/pubsublite/ProjectLookupUtils</className>
</difference>
<!-- Blanket ignored files -->
<difference>
Expand Down
5 changes: 0 additions & 5 deletions google-cloud-pubsublite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-resourcemanager</artifactId>
<version>0.118.4-alpha</version>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-pubsub-v1</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.google.cloud.pubsublite.cloudpubsub;

import static com.google.cloud.pubsublite.ProjectLookupUtils.toCanonical;

import com.google.api.gax.batching.BatchingSettings;
import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
Expand Down Expand Up @@ -119,17 +117,16 @@ Publisher instantiate() throws ApiException {
messageTransformer()
.orElseGet(() -> MessageTransforms.fromCpsPublishTransformer(keyExtractor));

TopicPath canonicalTopic = toCanonical(topicPath());
RoutingPublisherBuilder.Builder wireBuilder =
RoutingPublisherBuilder.newBuilder()
.setTopic(canonicalTopic)
.setTopic(topicPath())
.setPublisherFactory(
partition -> {
SinglePartitionPublisherBuilder.Builder singlePartitionBuilder =
underlyingBuilder()
.setBatchingSettings(batchingSettings)
.setContext(PubsubContext.of(FRAMEWORK))
.setTopic(canonicalTopic)
.setTopic(topicPath())
.setPartition(partition);
serviceClientSupplier()
.ifPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.google.cloud.pubsublite.cloudpubsub;

import static com.google.cloud.pubsublite.ProjectLookupUtils.toCanonical;
import static com.google.cloud.pubsublite.internal.ExtractStatus.toCanonical;
import static com.google.cloud.pubsublite.internal.UncheckedApiPreconditions.checkArgument;

Expand Down Expand Up @@ -177,13 +176,12 @@ PartitionSubscriberFactory makePartitionSubscriberFactory(SubscriptionPath canon

@SuppressWarnings("CheckReturnValue")
Subscriber instantiate() throws ApiException {
SubscriptionPath canonicalPath = toCanonical(subscriptionPath());
PartitionSubscriberFactory partitionSubscriberFactory =
makePartitionSubscriberFactory(canonicalPath);
makePartitionSubscriberFactory(subscriptionPath());

if (!partitions().isPresent()) {
AssignerBuilder.Builder assignerBuilder = AssignerBuilder.newBuilder();
assignerBuilder.setSubscriptionPath(canonicalPath);
assignerBuilder.setSubscriptionPath(subscriptionPath());
assignmentServiceClient().ifPresent(assignerBuilder::setServiceClient);
AssignerFactory assignerFactory =
receiver -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.cloud.pubsublite.AdminClient;
import com.google.cloud.pubsublite.CloudRegion;
import com.google.cloud.pubsublite.LocationPath;
import com.google.cloud.pubsublite.ProjectLookupUtils;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.TopicPath;
import com.google.cloud.pubsublite.proto.CreateSubscriptionRequest;
Expand Down Expand Up @@ -64,7 +63,7 @@ public CloudRegion region() {

@Override
public ApiFuture<Topic> createTopic(Topic topic) {
TopicPath path = ProjectLookupUtils.toCanonical(TopicPath.parse(topic.getName()));
TopicPath path = TopicPath.parse(topic.getName());
return serviceClient
.createTopicCallable()
.futureCall(
Expand All @@ -79,21 +78,15 @@ public ApiFuture<Topic> createTopic(Topic topic) {
public ApiFuture<Topic> getTopic(TopicPath path) {
return serviceClient
.getTopicCallable()
.futureCall(
GetTopicRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build());
.futureCall(GetTopicRequest.newBuilder().setName(path.toString()).build());
}

@Override
public ApiFuture<Long> getTopicPartitionCount(TopicPath path) {
return ApiFutures.transform(
serviceClient
.getTopicPartitionsCallable()
.futureCall(
GetTopicPartitionsRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build()),
.futureCall(GetTopicPartitionsRequest.newBuilder().setName(path.toString()).build()),
TopicPartitions::getPartitionCount,
MoreExecutors.directExecutor());
}
Expand All @@ -103,36 +96,24 @@ public ApiFuture<List<Topic>> listTopics(LocationPath path) {
return ApiFutures.transform(
serviceClient
.listTopicsCallable()
.futureCall(
ListTopicsRequest.newBuilder()
.setParent(ProjectLookupUtils.toCanonical(path).toString())
.build()),
.futureCall(ListTopicsRequest.newBuilder().setParent(path.toString()).build()),
ListTopicsResponse::getTopicsList,
MoreExecutors.directExecutor());
}

@Override
public ApiFuture<Topic> updateTopic(Topic topic, FieldMask mask) {
Topic canonical =
topic
.toBuilder()
.setName(ProjectLookupUtils.toCanonical(TopicPath.parse(topic.getName())).toString())
.build();
return serviceClient
.updateTopicCallable()
.futureCall(
UpdateTopicRequest.newBuilder().setTopic(canonical).setUpdateMask(mask).build());
.futureCall(UpdateTopicRequest.newBuilder().setTopic(topic).setUpdateMask(mask).build());
}

@Override
public ApiFuture<Void> deleteTopic(TopicPath path) {
return ApiFutures.transform(
serviceClient
.deleteTopicCallable()
.futureCall(
DeleteTopicRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build()),
.futureCall(DeleteTopicRequest.newBuilder().setName(path.toString()).build()),
x -> null,
MoreExecutors.directExecutor());
}
Expand All @@ -143,14 +124,11 @@ public ApiFuture<List<SubscriptionPath>> listTopicSubscriptions(TopicPath path)
serviceClient
.listTopicSubscriptionsCallable()
.futureCall(
ListTopicSubscriptionsRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build()),
ListTopicSubscriptionsRequest.newBuilder().setName(path.toString()).build()),
result -> {
ImmutableList.Builder<SubscriptionPath> builder = ImmutableList.builder();
for (String subscription : result.getSubscriptionsList()) {
SubscriptionPath subscription_path = SubscriptionPath.parse(subscription);
builder.add(subscription_path);
builder.add(SubscriptionPath.parse(subscription));
}
return builder.build();
},
Expand All @@ -159,8 +137,7 @@ public ApiFuture<List<SubscriptionPath>> listTopicSubscriptions(TopicPath path)

@Override
public ApiFuture<Subscription> createSubscription(Subscription subscription) {
SubscriptionPath path =
ProjectLookupUtils.toCanonical(SubscriptionPath.parse(subscription.getName()));
SubscriptionPath path = SubscriptionPath.parse(subscription.getName());
return serviceClient
.createSubscriptionCallable()
.futureCall(
Expand All @@ -175,39 +152,26 @@ public ApiFuture<Subscription> createSubscription(Subscription subscription) {
public ApiFuture<Subscription> getSubscription(SubscriptionPath path) {
return serviceClient
.getSubscriptionCallable()
.futureCall(
GetSubscriptionRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build());
.futureCall(GetSubscriptionRequest.newBuilder().setName(path.toString()).build());
}

@Override
public ApiFuture<List<Subscription>> listSubscriptions(LocationPath path) {
return ApiFutures.transform(
serviceClient
.listSubscriptionsCallable()
.futureCall(
ListSubscriptionsRequest.newBuilder()
.setParent(ProjectLookupUtils.toCanonical(path).toString())
.build()),
.futureCall(ListSubscriptionsRequest.newBuilder().setParent(path.toString()).build()),
ListSubscriptionsResponse::getSubscriptionsList,
MoreExecutors.directExecutor());
}

@Override
public ApiFuture<Subscription> updateSubscription(Subscription subscription, FieldMask mask) {
Subscription canonical =
subscription
.toBuilder()
.setName(
ProjectLookupUtils.toCanonical(SubscriptionPath.parse(subscription.getName()))
.toString())
.build();
return serviceClient
.updateSubscriptionCallable()
.futureCall(
UpdateSubscriptionRequest.newBuilder()
.setSubscription(canonical)
.setSubscription(subscription)
.setUpdateMask(mask)
.build());
}
Expand All @@ -217,10 +181,7 @@ public ApiFuture<Void> deleteSubscription(SubscriptionPath path) {
return ApiFutures.transform(
serviceClient
.deleteSubscriptionCallable()
.futureCall(
DeleteSubscriptionRequest.newBuilder()
.setName(ProjectLookupUtils.toCanonical(path).toString())
.build()),
.futureCall(DeleteSubscriptionRequest.newBuilder().setName(path.toString()).build()),
x -> null,
MoreExecutors.directExecutor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.cloud.pubsublite.CloudRegion;
import com.google.cloud.pubsublite.Offset;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.ProjectLookupUtils;
import com.google.cloud.pubsublite.TopicPath;
import com.google.cloud.pubsublite.proto.ComputeMessageStatsRequest;
import com.google.cloud.pubsublite.proto.ComputeMessageStatsResponse;
Expand Down Expand Up @@ -48,7 +47,7 @@ public ApiFuture<ComputeMessageStatsResponse> computeMessageStats(
.computeMessageStatsCallable()
.futureCall(
ComputeMessageStatsRequest.newBuilder()
.setTopic(ProjectLookupUtils.toCanonical(path).toString())
.setTopic(path.toString())
.setPartition(partition.value())
.setStartCursor(Cursor.newBuilder().setOffset(start.value()).build())
.setEndCursor(Cursor.newBuilder().setOffset(end.value()).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.ProjectLookupUtils;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.proto.InitialPartitionAssignmentRequest;
import com.google.cloud.pubsublite.v1.PartitionAssignmentServiceClient;
Expand Down Expand Up @@ -87,8 +86,7 @@ public Assigner build() throws ApiException {

InitialPartitionAssignmentRequest initial =
InitialPartitionAssignmentRequest.newBuilder()
.setSubscription(
ProjectLookupUtils.toCanonical(builder.subscriptionPath()).toString())
.setSubscription(builder.subscriptionPath().toString())
.setClientId(ByteString.copyFrom(uuidBuffer.array()))
.build();
return new AssignerImpl(serviceClient, initial, builder.receiver());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.ProjectLookupUtils;
import com.google.cloud.pubsublite.SubscriptionPath;
import com.google.cloud.pubsublite.proto.InitialCommitCursorRequest;
import com.google.cloud.pubsublite.v1.CursorServiceClient;
Expand Down Expand Up @@ -76,8 +75,7 @@ public Committer build() throws ApiException {

InitialCommitCursorRequest initialCommitCursorRequest =
InitialCommitCursorRequest.newBuilder()
.setSubscription(
ProjectLookupUtils.toCanonical(builder.subscriptionPath()).toString())
.setSubscription(builder.subscriptionPath().toString())
.setPartition(builder.partition().value())
.build();
return new ApiExceptionCommitter(
Expand Down
Loading

0 comments on commit 14e5ab4

Please sign in to comment.