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

Updating pubsub to match gax-java 0.0.12 #981

Merged
merged 2 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -52,6 +52,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;

// Manually-added imports: add custom (non-generated) imports after this point.

Expand All @@ -65,10 +66,10 @@
*
* <pre>
* <code>
* try (PublisherApi publisherApi = PublisherApi.defaultInstance()) {
* // make calls here
* String name = "";
* Topic callResult = createTopic(name);
* try (PublisherApi publisherApi = PublisherApi.createWithDefaults()) {
* String name = "";
*

This comment was marked as spam.

* Topic callResult = publisherApi.createTopic(name);
* }
* </code>
* </pre>
Expand Down Expand Up @@ -100,15 +101,10 @@
* <p>This class can be customized by passing in a custom instance of PublisherSettings to
* create(). For example:
*
* <!-- TODO(garrettjones) refactor code to make this simpler -->
* <pre>
* <code>
* ConnectionSettings defaultConnectionSettings =
* PublisherSettings.defaultInstance().toBuilder().getConnectionSettings();
* ConnectionSettings updatedConnectionSettings =
* defaultConnectionSettings.toBuilder().provideCredentialsWith(myCredentials).build();
* PublisherSettings publisherSettings = PublisherSettings.defaultInstance().toBuilder().
* provideChannelWith(updatedConnectionSettings)
* PublisherSettings publisherSettings = PublisherSettings.defaultBuilder()
* .provideChannelWith(myCredentials)
* .build();
* PublisherApi publisherApi = PublisherApi.create(publisherSettings);
* </code>
Expand All @@ -119,7 +115,9 @@
*/
@javax.annotation.Generated("by GAPIC")
public class PublisherApi implements AutoCloseable {
private final PublisherSettings settings;
private final ManagedChannel channel;
private final ScheduledExecutorService executor;
private final List<AutoCloseable> closeables = new ArrayList<>();

private final ApiCallable<Topic, Topic> createTopicCallable;
Expand All @@ -133,11 +131,15 @@ public class PublisherApi implements AutoCloseable {
listTopicSubscriptionsPagedCallable;
private final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable;

public final PublisherSettings getSettings() {
return settings;
}

private static final PathTemplate PROJECT_PATH_TEMPLATE =

This comment was marked as spam.

PathTemplate.create("projects/{project}");
PathTemplate.createWithoutUrlEncoding("projects/{project}");

private static final PathTemplate TOPIC_PATH_TEMPLATE =

This comment was marked as spam.

PathTemplate.create("projects/{project}/topics/{topic}");
PathTemplate.createWithoutUrlEncoding("projects/{project}/topics/{topic}");

/**
* Formats a string containing the fully-qualified path to represent
Expand Down Expand Up @@ -200,8 +202,8 @@ public static final String parseTopicFromTopicName(String topicName) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final PublisherApi defaultInstance() throws IOException {
return create(PublisherSettings.defaultInstance());
public static final PublisherApi createWithDefaults() throws IOException {
return create(PublisherSettings.defaultBuilder().build());
}

/**
Expand All @@ -225,24 +227,32 @@ public static final PublisherApi create(PublisherSettings settings) throws IOExc
* <!-- end manual edit -->
*/
protected PublisherApi(PublisherSettings settings) throws IOException {
this.channel = settings.getChannel();

this.createTopicCallable = ApiCallable.create(settings.createTopicSettings(), settings);
this.publishCallable = ApiCallable.create(settings.publishSettings(), settings);
this.settings = settings;
this.executor = settings.getExecutorProvider().getOrBuildExecutor();
this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);

this.createTopicCallable =
ApiCallable.create(settings.createTopicSettings(), this.channel, this.executor);
this.publishCallable =
ApiCallable.create(settings.publishSettings(), this.channel, this.executor);
if (settings.publishSettings().getBundlerFactory() != null) {
closeables.add(settings.publishSettings().getBundlerFactory());
}
this.getTopicCallable = ApiCallable.create(settings.getTopicSettings(), settings);
this.listTopicsCallable = ApiCallable.create(settings.listTopicsSettings(), settings);
this.getTopicCallable =
ApiCallable.create(settings.getTopicSettings(), this.channel, this.executor);
this.listTopicsCallable =
ApiCallable.create(settings.listTopicsSettings(), this.channel, this.executor);
this.listTopicsPagedCallable =
ApiCallable.createPagedVariant(settings.listTopicsSettings(), settings);
ApiCallable.createPagedVariant(settings.listTopicsSettings(), this.channel, this.executor);
this.listTopicSubscriptionsCallable =
ApiCallable.create(settings.listTopicSubscriptionsSettings(), settings);
ApiCallable.create(settings.listTopicSubscriptionsSettings(), this.channel, this.executor);
this.listTopicSubscriptionsPagedCallable =
ApiCallable.createPagedVariant(settings.listTopicSubscriptionsSettings(), settings);
this.deleteTopicCallable = ApiCallable.create(settings.deleteTopicSettings(), settings);
ApiCallable.createPagedVariant(
settings.listTopicSubscriptionsSettings(), this.channel, this.executor);
this.deleteTopicCallable =
ApiCallable.create(settings.deleteTopicSettings(), this.channel, this.executor);

if (settings.shouldAutoCloseChannel()) {
if (settings.getChannelProvider().shouldAutoClose()) {
closeables.add(
new Closeable() {
@Override
Expand All @@ -251,6 +261,15 @@ public void close() throws IOException {
}
});
}
if (settings.getExecutorProvider().shouldAutoClose()) {
closeables.add(
new Closeable() {
@Override
public void close() throws IOException {
executor.shutdown();
}
});
}
}

// ----- createTopic -----
Expand Down Expand Up @@ -296,7 +315,6 @@ private Topic createTopic(Topic request) {
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<Topic, Topic> createTopicCallable() {
return createTopicCallable;
Expand All @@ -306,7 +324,7 @@ public final ApiCallable<Topic, Topic> createTopicCallable() {

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic
* Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic

This comment was marked as spam.

* does not exist. The message payload must not be empty; it must contain
* either a non-empty data field, or at least one attribute.
*
Expand All @@ -326,7 +344,7 @@ public final PublishResponse publish(String topic, List<PubsubMessage> messages)

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic
* Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
* does not exist. The message payload must not be empty; it must contain
* either a non-empty data field, or at least one attribute.
*
Expand All @@ -342,13 +360,12 @@ public PublishResponse publish(PublishRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Adds one or more messages to the topic. Generates `NOT_FOUND` if the topic
* Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
* does not exist. The message payload must not be empty; it must contain
* either a non-empty data field, or at least one attribute.
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<PublishRequest, PublishResponse> publishCallable() {
return publishCallable;
Expand Down Expand Up @@ -392,7 +409,6 @@ private Topic getTopic(GetTopicRequest request) {
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
return getTopicCallable;
Expand Down Expand Up @@ -435,7 +451,6 @@ public final PageAccessor<Topic> listTopics(ListTopicsRequest request) {
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<ListTopicsRequest, PageAccessor<Topic>> listTopicsPagedCallable() {
return listTopicsPagedCallable;
Expand All @@ -447,7 +462,6 @@ public final ApiCallable<ListTopicsRequest, PageAccessor<Topic>> listTopicsPaged
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() {
return listTopicsCallable;
Expand Down Expand Up @@ -491,7 +505,6 @@ public final PageAccessor<String> listTopicSubscriptions(ListTopicSubscriptionsR
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<ListTopicSubscriptionsRequest, PageAccessor<String>>
listTopicSubscriptionsPagedCallable() {
Expand All @@ -504,7 +517,6 @@ public final PageAccessor<String> listTopicSubscriptions(ListTopicSubscriptionsR
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse>
listTopicSubscriptionsCallable() {
Expand All @@ -515,7 +527,7 @@ public final PageAccessor<String> listTopicSubscriptions(ListTopicSubscriptionsR

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Deletes the topic with the given name. Generates `NOT_FOUND` if the topic
* Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
* does not exist. After a topic is deleted, a new topic may be created with
* the same name; this is an entirely new topic with none of the old
* configuration or subscriptions. Existing subscriptions to this topic are
Expand All @@ -535,7 +547,7 @@ public final void deleteTopic(String topic) {

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Deletes the topic with the given name. Generates `NOT_FOUND` if the topic
* Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
* does not exist. After a topic is deleted, a new topic may be created with
* the same name; this is an entirely new topic with none of the old
* configuration or subscriptions. Existing subscriptions to this topic are
Expand All @@ -553,15 +565,14 @@ private void deleteTopic(DeleteTopicRequest request) {

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Deletes the topic with the given name. Generates `NOT_FOUND` if the topic
* Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
* does not exist. After a topic is deleted, a new topic may be created with
* the same name; this is an entirely new topic with none of the old
* configuration or subscriptions. Existing subscriptions to this topic are
* not deleted, but their `topic` field is set to `_deleted-topic_`.
*
* <!-- manual edit -->
* <!-- end manual edit -->
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() {
return deleteTopicCallable;
Expand Down
Loading