Skip to content

Commit d0bc287

Browse files
Updates due to code gen
1 parent 6701117 commit d0bc287

File tree

6 files changed

+163
-158
lines changed

6 files changed

+163
-158
lines changed

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ public static PublisherApi create(PublisherSettings settings) throws IOException
213213
protected PublisherApi(PublisherSettings settings) throws IOException {
214214
this.channel = settings.getChannel();
215215

216-
for (ApiCallSettings method : settings.allMethods()) {
217-
if (method.getExecutor() == null) {
218-
method.setExecutor(settings.getExecutor());
219-
}
220-
}
221-
222216
this.createTopicCallable = settings.createTopicMethod().build(settings);
223217
this.publishCallable = settings.publishMethod().build(settings);
224218
this.getTopicCallable = settings.getTopicMethod().build(settings);

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.google.api.gax.grpc.ApiCallable.ApiCallableBuilder;
4141
import com.google.api.gax.grpc.ApiCallable.PageStreamingApiCallableBuilder;
4242
import com.google.api.gax.grpc.PageDescriptor;
43+
import com.google.api.gax.grpc.ServiceApiSettings;
4344
import com.google.common.collect.ImmutableList;
4445
import com.google.common.collect.ImmutableMap;
4546
import com.google.common.collect.ImmutableSet;
@@ -62,7 +63,7 @@
6263

6364
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
6465
@javax.annotation.Generated("by GAPIC")
65-
public class PublisherSettings extends ApiCallSettings {
66+
public class PublisherSettings extends ServiceApiSettings {
6667

6768
// =========
6869
// Constants
@@ -131,16 +132,62 @@ public class PublisherSettings extends ApiCallSettings {
131132
RETRY_PARAM_DEFINITIONS = definitions.build();
132133
}
133134

134-
private final ApiCallableBuilder<Topic, Topic> createTopicMethod;
135-
private final ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod;
136-
private final ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod;
137-
private final PageStreamingApiCallableBuilder<ListTopicsRequest, ListTopicsResponse, Topic>
138-
listTopicsMethod;
139-
private final PageStreamingApiCallableBuilder<
140-
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
141-
listTopicSubscriptionsMethod;
142-
private final ApiCallableBuilder<DeleteTopicRequest, Empty> deleteTopicMethod;
143-
private final ImmutableList<? extends ApiCallSettings> allMethods;
135+
private static class MethodBuilders {
136+
private final ApiCallableBuilder<Topic, Topic> createTopicMethod;
137+
private final ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod;
138+
private final ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod;
139+
private final PageStreamingApiCallableBuilder<ListTopicsRequest, ListTopicsResponse, Topic>
140+
listTopicsMethod;
141+
private final PageStreamingApiCallableBuilder<
142+
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
143+
listTopicSubscriptionsMethod;
144+
private final ApiCallableBuilder<DeleteTopicRequest, Empty> deleteTopicMethod;
145+
private final ImmutableList<? extends ApiCallSettings> allMethods;
146+
147+
public MethodBuilders() {
148+
createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC);
149+
createTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
150+
createTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
151+
152+
publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH);
153+
publishMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"));
154+
publishMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
155+
156+
getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC);
157+
getTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
158+
getTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
159+
160+
listTopicsMethod =
161+
new PageStreamingApiCallableBuilder<>(
162+
PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC);
163+
listTopicsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
164+
listTopicsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
165+
166+
listTopicSubscriptionsMethod =
167+
new PageStreamingApiCallableBuilder<>(
168+
PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS,
169+
LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC);
170+
listTopicSubscriptionsMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
171+
listTopicSubscriptionsMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
172+
173+
deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC);
174+
deleteTopicMethod.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"));
175+
deleteTopicMethod.setRetryParams(RETRY_PARAM_DEFINITIONS.get("default"));
176+
177+
allMethods =
178+
ImmutableList.<ApiCallSettings>builder()
179+
.add(
180+
createTopicMethod,
181+
publishMethod,
182+
getTopicMethod,
183+
listTopicsMethod,
184+
listTopicSubscriptionsMethod,
185+
deleteTopicMethod)
186+
.build();
187+
}
188+
}
189+
190+
private final MethodBuilders methods;
144191

145192
// ===============
146193
// Factory Methods
@@ -153,7 +200,7 @@ public class PublisherSettings extends ApiCallSettings {
153200
* <!-- end manual edit -->
154201
*/
155202
public static PublisherSettings create() {
156-
PublisherSettings settings = new PublisherSettings();
203+
PublisherSettings settings = new PublisherSettings(new MethodBuilders());
157204
settings.provideChannelWith(
158205
ConnectionSettings.builder()
159206
.setServiceAddress(DEFAULT_SERVICE_ADDRESS)
@@ -170,45 +217,9 @@ public static PublisherSettings create() {
170217
* <!-- manual edit -->
171218
* <!-- end manual edit -->
172219
*/
173-
protected PublisherSettings() {
174-
createTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_CREATE_TOPIC);
175-
createTopicMethod.setRetryDefaults(
176-
RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
177-
178-
publishMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_PUBLISH);
179-
publishMethod.setRetryDefaults(
180-
RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
181-
182-
getTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_GET_TOPIC);
183-
getTopicMethod.setRetryDefaults(
184-
RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
185-
186-
listTopicsMethod =
187-
new PageStreamingApiCallableBuilder<>(
188-
PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC);
189-
listTopicsMethod.setRetryDefaults(
190-
RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
191-
192-
listTopicSubscriptionsMethod =
193-
new PageStreamingApiCallableBuilder<>(
194-
PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS, LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC);
195-
listTopicSubscriptionsMethod.setRetryDefaults(
196-
RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
197-
198-
deleteTopicMethod = new ApiCallableBuilder<>(PublisherGrpc.METHOD_DELETE_TOPIC);
199-
deleteTopicMethod.setRetryDefaults(
200-
RETRYABLE_CODE_DEFINITIONS.get("idempotent"), RETRY_PARAM_DEFINITIONS.get("default"));
201-
202-
allMethods =
203-
ImmutableList.<ApiCallSettings>builder()
204-
.add(
205-
createTopicMethod,
206-
publishMethod,
207-
getTopicMethod,
208-
listTopicsMethod,
209-
listTopicSubscriptionsMethod,
210-
deleteTopicMethod)
211-
.build();
220+
protected PublisherSettings(MethodBuilders methods) {
221+
super(methods.allMethods);
222+
this.methods = methods;
212223
}
213224

214225
/**
@@ -218,7 +229,7 @@ protected PublisherSettings() {
218229
* <!-- end manual edit -->
219230
*/
220231
public ApiCallableBuilder<Topic, Topic> createTopicMethod() {
221-
return createTopicMethod;
232+
return methods.createTopicMethod;
222233
}
223234

224235
/**
@@ -228,7 +239,7 @@ public ApiCallableBuilder<Topic, Topic> createTopicMethod() {
228239
* <!-- end manual edit -->
229240
*/
230241
public ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod() {
231-
return publishMethod;
242+
return methods.publishMethod;
232243
}
233244

234245
/**
@@ -238,7 +249,7 @@ public ApiCallableBuilder<PublishRequest, PublishResponse> publishMethod() {
238249
* <!-- end manual edit -->
239250
*/
240251
public ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod() {
241-
return getTopicMethod;
252+
return methods.getTopicMethod;
242253
}
243254

244255
/**
@@ -249,7 +260,7 @@ public ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod() {
249260
*/
250261
public PageStreamingApiCallableBuilder<ListTopicsRequest, ListTopicsResponse, Topic>
251262
listTopicsMethod() {
252-
return listTopicsMethod;
263+
return methods.listTopicsMethod;
253264
}
254265

255266
/**
@@ -261,7 +272,7 @@ public ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod() {
261272
public PageStreamingApiCallableBuilder<
262273
ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
263274
listTopicSubscriptionsMethod() {
264-
return listTopicSubscriptionsMethod;
275+
return methods.listTopicSubscriptionsMethod;
265276
}
266277

267278
/**
@@ -271,11 +282,7 @@ public ApiCallableBuilder<GetTopicRequest, Topic> getTopicMethod() {
271282
* <!-- end manual edit -->
272283
*/
273284
public ApiCallableBuilder<DeleteTopicRequest, Empty> deleteTopicMethod() {
274-
return deleteTopicMethod;
275-
}
276-
277-
public ImmutableList<? extends ApiCallSettings> allMethods() {
278-
return allMethods;
285+
return methods.deleteTopicMethod;
279286
}
280287

281288
private static PageDescriptor<ListTopicsRequest, ListTopicsResponse, Topic>

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,6 @@ public static SubscriberApi create(SubscriberSettings settings) throws IOExcepti
216216
protected SubscriberApi(SubscriberSettings settings) throws IOException {
217217
this.channel = settings.getChannel();
218218

219-
for (ApiCallSettings method : settings.allMethods()) {
220-
if (method.getExecutor() == null) {
221-
method.setExecutor(settings.getExecutor());
222-
}
223-
}
224-
225219
this.createSubscriptionCallable = settings.createSubscriptionMethod().build(settings);
226220
this.getSubscriptionCallable = settings.getSubscriptionMethod().build(settings);
227221
this.listSubscriptionsCallable = settings.listSubscriptionsMethod().build(settings);

0 commit comments

Comments
 (0)