Skip to content
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
68 changes: 68 additions & 0 deletions google-cloud-pubsublite/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
<?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>
<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>
</difference>
<!-- Blanket ignored files -->
<difference>
<differenceType>4001</differenceType>
<className>com/google/cloud/pubsublite/internal/**</className>
<to>**</to>
</difference>
<difference>
<differenceType>5001</differenceType>
<className>com/google/cloud/pubsublite/internal/**</className>
Expand All @@ -27,6 +74,11 @@
<className>com/google/cloud/pubsublite/internal/**</className>
<method>*</method>
</difference>
<difference>
<differenceType>7004</differenceType>
<className>com/google/cloud/pubsublite/internal/**</className>
<method>*</method>
</difference>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/pubsublite/internal/**</className>
Expand All @@ -39,6 +91,11 @@
<method>*</method>
<to>*</to>
</difference>
<difference>
<differenceType>7009</differenceType>
<className>com/google/cloud/pubsublite/internal/**</className>
<method>*</method>
</difference>
<difference>
<differenceType>7011</differenceType>
<className>com/google/cloud/pubsublite/internal/*</className>
Expand Down Expand Up @@ -100,12 +157,23 @@
<className>com/google/cloud/pubsublite/cloudpubsub/internal/**</className>
<method>*</method>
</difference>
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/internal/**</className>
<method>*</method>
<to>*</to>
</difference>
<difference>
<differenceType>7006</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/internal/**</className>
<method>*</method>
<to>*</to>
</difference>
<difference>
<differenceType>7009</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/internal/**</className>
<method>*</method>
</difference>
<difference>
<differenceType>7011</differenceType>
<className>com/google/cloud/pubsublite/cloudpubsub/internal/**</className>
Expand Down
17 changes: 0 additions & 17 deletions google-cloud-pubsublite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-auth</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
Expand Down Expand Up @@ -94,10 +86,6 @@
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
Expand Down Expand Up @@ -135,11 +123,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
package com.google.cloud.pubsublite;

import com.google.api.core.ApiFuture;
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.pubsublite.internal.ApiBackgroundResource;
import com.google.cloud.pubsublite.proto.Subscription;
import com.google.cloud.pubsublite.proto.Topic;
import com.google.protobuf.FieldMask;
import io.grpc.StatusException;
import java.util.List;

/** A client for performing Pub/Sub Lite admin operations. */
public interface AdminClient extends ApiBackgroundResource {
static AdminClient create(AdminClientSettings settings) throws StatusException {
static AdminClient create(AdminClientSettings settings) throws ApiException {
return settings.instantiate();
}

Expand All @@ -37,35 +37,35 @@ static AdminClient create(AdminClientSettings settings) throws StatusException {
* Create the provided topic if it does not yet exist.
*
* @param topic The topic to create.
* @return A future that will have either an error {@link io.grpc.StatusException} or the topic on
* success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the topic on success.
*/
ApiFuture<Topic> createTopic(Topic topic);

/**
* Get the topic with id {@code id} if it exists.
*
* @param path The path of the topic to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or the topic on
* success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the topic on success.
*/
ApiFuture<Topic> getTopic(TopicPath path);

/**
* Get the partitioning info for the topic with id {@code id} if it exists.
*
* @param path The path of the topic to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or the number
* of topic partitions on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the number of topic partitions on success.
*/
ApiFuture<Long> getTopicPartitionCount(TopicPath path);

/**
* List all topics for the specified project.
*
* @param path The path of the project to list topics for.
* @return A future that will have either an error {@link io.grpc.StatusException} or the list of
* topic paths on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the list of topic paths on success.
*/
ApiFuture<List<Topic>> listTopics(LocationPath path);

Expand All @@ -74,55 +74,55 @@ static AdminClient create(AdminClientSettings settings) throws StatusException {
*
* @param topic The topic to update.
* @param mask The mask indicating which fields should be updated.
* @return A future that will have either an error {@link io.grpc.StatusException} or the
* resulting topic on success. Updating nonexistent topics will cause the future to have an
* exception with status {@link io.grpc.Status.Code#NOT_FOUND}
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the resulting topic on success. Updating nonexistent topics will cause the future to have
* an exception with status {@link com.google.api.gax.rpc.StatusCode.Code#NOT_FOUND}
*/
ApiFuture<Topic> updateTopic(Topic topic, FieldMask mask);

/**
* Delete the topic with id {@code id} if it exists.
*
* @param path The path of the topic to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or void on
* success. Deleting nonexistent topics will cause the future to have an exception with status
* {@link io.grpc.Status.Code#NOT_FOUND}
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* void on success. Deleting nonexistent topics will cause the future to have an exception
* with status {@link com.google.api.gax.rpc.StatusCode.Code#NOT_FOUND}
*/
ApiFuture<Void> deleteTopic(TopicPath path);

/**
* Get the list of subscriptions for the topic with id {@code id} if it exists.
*
* @param path The path of the topic to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or the list of
* subscriptions on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the list of subscriptions on success.
*/
ApiFuture<List<SubscriptionPath>> listTopicSubscriptions(TopicPath path);

/**
* Create the provided subscription if it does not yet exist.
*
* @param subscription The subscription to create.
* @return A future that will have either an error {@link io.grpc.StatusException} or the
* subscription on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the subscription on success.
*/
ApiFuture<Subscription> createSubscription(Subscription subscription);

/**
* Get the subscription with id {@code id} if it exists.
*
* @param path The path of the subscription to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or the
* subscription on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the subscription on success.
*/
ApiFuture<Subscription> getSubscription(SubscriptionPath path);

/**
* List all subscriptions for the specified project.
*
* @param path The path of the project to list subscriptions for.
* @return A future that will have either an error {@link io.grpc.StatusException} or the list of
* subscription paths on success.
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the list of subscription paths on success.
*/
ApiFuture<List<Subscription>> listSubscriptions(LocationPath path);

Expand All @@ -131,19 +131,20 @@ static AdminClient create(AdminClientSettings settings) throws StatusException {
*
* @param subscription The subscription to update.
* @param mask The mask indicating which fields should be updated.
* @return A future that will have either an error {@link io.grpc.StatusException} or the
* resulting subscription on success. Updating nonexistent subscriptions will cause the future
* to have an exception with status {@link io.grpc.Status.Code#NOT_FOUND}
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* the resulting subscription on success. Updating nonexistent subscriptions will cause the
* future to have an exception with status {@link
* com.google.api.gax.rpc.StatusCode.Code#NOT_FOUND}
*/
ApiFuture<Subscription> updateSubscription(Subscription subscription, FieldMask mask);

/**
* Delete the subscription with id {@code id} if it exists.
*
* @param path The path of the subscription to retrieve.
* @return A future that will have either an error {@link io.grpc.StatusException} or void on
* success. Deleting nonexistent subscriptions will cause the future to have an exception with
* status {@link io.grpc.Status.Code#NOT_FOUND}
* @return A future that will have either an error {@link com.google.api.gax.rpc.ApiException} or
* void on success. Deleting nonexistent subscriptions will cause the future to have an
* exception with status {@link com.google.api.gax.rpc.StatusCode.Code#NOT_FOUND}
*/
ApiFuture<Void> deleteSubscription(SubscriptionPath path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@

package com.google.cloud.pubsublite;

import static com.google.cloud.pubsublite.internal.ServiceClients.addDefaultSettings;

import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.internal.AdminClientImpl;
import com.google.cloud.pubsublite.proto.AdminServiceGrpc;
import com.google.cloud.pubsublite.proto.AdminServiceGrpc.AdminServiceBlockingStub;
import io.grpc.StatusException;
import com.google.cloud.pubsublite.internal.ExtractStatus;
import com.google.cloud.pubsublite.v1.AdminServiceClient;
import com.google.cloud.pubsublite.v1.AdminServiceSettings;
import java.util.Optional;

/** Settings for construction a Pub/Sub Lite AdminClient. */
@AutoValue
public abstract class AdminClientSettings {

// Required parameters.

/**
* The <a href="https://cloud.google.com/pubsub/lite/docs/locations">cloud region</a> to perform
* admin operations for.
*/
abstract CloudRegion region();

// Optional parameters.

/** The retry settings for this client. */
abstract RetrySettings retrySettings();
abstract Optional<RetrySettings> retrySettings();

/** A stub to use to connect. */
abstract Optional<AdminServiceBlockingStub> stub();
abstract Optional<AdminServiceClient> serviceClient();

public static Builder newBuilder() {
return new AutoValue_AdminClientSettings.Builder()
Expand All @@ -61,20 +61,33 @@ public abstract static class Builder {
/** The retry settings for this client. */
public abstract Builder setRetrySettings(RetrySettings retrySettings);

/** A stub to use to connect. */
public abstract Builder setStub(AdminServiceBlockingStub stub);
/** A service client to use to connect. */
public abstract Builder setServiceClient(AdminServiceClient serviceClient);

/** Build the settings object. */
public abstract AdminClientSettings build();
}

AdminClient instantiate() throws StatusException {
AdminServiceBlockingStub stub;
if (stub().isPresent()) {
stub = stub().get();
AdminClient instantiate() throws ApiException {
AdminServiceClient serviceClient;
if (serviceClient().isPresent()) {
serviceClient = serviceClient().get();
} else {
stub = Stubs.defaultStub(region(), AdminServiceGrpc::newBlockingStub);
try {
AdminServiceSettings.Builder builder =
addDefaultSettings(region(), AdminServiceSettings.newBuilder()).toBuilder();
if (retrySettings().isPresent()) {
builder.applyToAllUnaryMethods(
callBuilder -> {
callBuilder.setRetrySettings(retrySettings().get());
return null;
});
}
serviceClient = AdminServiceClient.create(builder.build());
} catch (Throwable t) {
throw ExtractStatus.toCanonical(t).underlying;
}
}
return new AdminClientImpl(region(), stub, retrySettings());
return new AdminClientImpl(region(), serviceClient);
}
}
Loading