18
18
import com .google .api .core .ApiFunction ;
19
19
import com .google .api .core .ApiFuture ;
20
20
import com .google .api .core .BetaApi ;
21
- import com .google .api .gax .batching .BatchingSettings ;
22
- import com .google .api .gax .batching .FlowControlSettings ;
23
- import com .google .api .gax .batching .FlowController .LimitExceededBehavior ;
24
- import com .google .api .gax .batching .PartitionKey ;
25
- import com .google .api .gax .batching .RequestBuilder ;
26
21
import com .google .api .gax .core .GaxProperties ;
27
22
import com .google .api .gax .core .GoogleCredentialsProvider ;
28
23
import com .google .api .gax .core .InstantiatingExecutorProvider ;
35
30
import com .google .api .gax .retrying .RetrySettings ;
36
31
import com .google .api .gax .rpc .ApiCallContext ;
37
32
import com .google .api .gax .rpc .ApiClientHeaderProvider ;
38
- import com .google .api .gax .rpc .BatchedRequestIssuer ;
39
- import com .google .api .gax .rpc .BatchingCallSettings ;
40
- import com .google .api .gax .rpc .BatchingDescriptor ;
41
33
import com .google .api .gax .rpc .ClientContext ;
42
34
import com .google .api .gax .rpc .OperationCallSettings ;
43
35
import com .google .api .gax .rpc .PageContext ;
82
74
import com .google .api .generator .engine .ast .Variable ;
83
75
import com .google .api .generator .engine .ast .VariableExpr ;
84
76
import com .google .api .generator .gapic .model .Field ;
85
- import com .google .api .generator .gapic .model .GapicBatchingSettings ;
86
77
import com .google .api .generator .gapic .model .GapicClass ;
87
78
import com .google .api .generator .gapic .model .GapicServiceConfig ;
88
79
import com .google .api .generator .gapic .model .Message ;
@@ -221,12 +212,8 @@ private static Map<String, VariableExpr> createMethodSettingsClassMemberVarExprs
221
212
Map <String , VariableExpr > varExprs = new LinkedHashMap <>();
222
213
223
214
// Creates class variables <method>Settings, e.g. echoSettings.
224
- // TODO(miraleung): Handle batching here.
225
215
for (Method method : service .methods ()) {
226
- boolean hasBatchingSettings =
227
- !Objects .isNull (serviceConfig ) && serviceConfig .hasBatchingSetting (service , method );
228
- TypeNode settingsType =
229
- getCallSettingsType (method , types , hasBatchingSettings , isNestedClass );
216
+ TypeNode settingsType = getCallSettingsType (method , types , isNestedClass );
230
217
String varName = JavaStyle .toLowerCamelCase (String .format ("%sSettings" , method .name ()));
231
218
varExprs .put (
232
219
varName ,
@@ -313,20 +300,6 @@ private static List<Statement> createClassStatements(
313
300
statements .add (EMPTY_LINE_STATEMENT );
314
301
}
315
302
316
- for (Method method : service .methods ()) {
317
- Optional <GapicBatchingSettings > batchingSettingOpt =
318
- Objects .isNull (serviceConfig )
319
- ? Optional .empty ()
320
- : serviceConfig .getBatchingSetting (service , method );
321
- if (batchingSettingOpt .isPresent ()) {
322
- statements .add (
323
- exprToStatementFn .apply (
324
- BatchingDescriptorComposer .createBatchingDescriptorFieldDeclExpr (
325
- method , batchingSettingOpt .get (), messageTypes )));
326
- }
327
- statements .add (EMPTY_LINE_STATEMENT );
328
- }
329
-
330
303
return statements ;
331
304
}
332
305
@@ -1261,22 +1234,6 @@ private static MethodDefinition createNestedClassInitDefaultsMethod(
1261
1234
if (streamKind .equals (Method .Stream .CLIENT ) || streamKind .equals (Method .Stream .BIDI )) {
1262
1235
continue ;
1263
1236
}
1264
- if (!Objects .isNull (serviceConfig ) && serviceConfig .hasBatchingSetting (service , method )) {
1265
- Optional <GapicBatchingSettings > batchingSettingOpt =
1266
- serviceConfig .getBatchingSetting (service , method );
1267
- Preconditions .checkState (
1268
- batchingSettingOpt .isPresent (),
1269
- String .format (
1270
- "No batching setting found for service %s, method %s" ,
1271
- service .name (), method .name ()));
1272
- String settingsGetterMethodName =
1273
- String .format ("%sSettings" , JavaStyle .toLowerCamelCase (method .name ()));
1274
- bodyStatements .add (
1275
- ExprStatement .withExpr (
1276
- RetrySettingsComposer .createBatchingBuilderSettingsExpr (
1277
- settingsGetterMethodName , batchingSettingOpt .get (), builderVarExpr )));
1278
- bodyStatements .add (EMPTY_LINE_STATEMENT );
1279
- }
1280
1237
1281
1238
bodyStatements .add (
1282
1239
ExprStatement .withExpr (
@@ -1352,8 +1309,6 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
1352
1309
.build ());
1353
1310
Reference pagedSettingsBuilderRef =
1354
1311
ConcreteReference .withClazz (PagedCallSettings .Builder .class );
1355
- Reference batchingSettingsBuilderRef =
1356
- ConcreteReference .withClazz (BatchingCallSettings .Builder .class );
1357
1312
Reference unaryCallSettingsBuilderRef =
1358
1313
ConcreteReference .withClazz (UnaryCallSettings .Builder .class );
1359
1314
Function <TypeNode , Boolean > isUnaryCallSettingsBuilderFn =
@@ -1363,9 +1318,6 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
1363
1318
.equals (unaryCallSettingsBuilderRef );
1364
1319
Function <TypeNode , Boolean > isPagedCallSettingsBuilderFn =
1365
1320
t -> t .reference ().copyAndSetGenerics (ImmutableList .of ()).equals (pagedSettingsBuilderRef );
1366
- Function <TypeNode , Boolean > isBatchingCallSettingsBuilderFn =
1367
- t ->
1368
- t .reference ().copyAndSetGenerics (ImmutableList .of ()).equals (batchingSettingsBuilderRef );
1369
1321
Function <TypeNode , TypeNode > builderToCallSettingsFn =
1370
1322
t ->
1371
1323
TypeNode .withReference (
@@ -1396,61 +1348,20 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
1396
1348
String methodName = getMethodNameFromSettingsVarName (e .getKey ());
1397
1349
1398
1350
if (!isPagedCallSettingsBuilderFn .apply (varType )) {
1399
- if (!isBatchingCallSettingsBuilderFn .apply (varType )) {
1400
- boolean isUnaryCallSettings = isUnaryCallSettingsBuilderFn .apply (varType );
1401
- Expr builderExpr =
1402
- AssignmentExpr .builder ()
1403
- .setVariableExpr (varExpr )
1404
- .setValueExpr (
1405
- MethodInvocationExpr .builder ()
1406
- .setStaticReferenceType (
1407
- builderToCallSettingsFn .apply (varExpr .type ()))
1408
- .setMethodName (
1409
- isUnaryCallSettings
1410
- ? "newUnaryCallSettingsBuilder"
1411
- : "newBuilder" )
1412
- .setReturnType (varExpr .type ())
1413
- .build ())
1414
- .build ();
1415
- return ExprStatement .withExpr (builderExpr );
1416
- }
1417
- Expr newBatchingSettingsExpr =
1418
- MethodInvocationExpr .builder ()
1419
- .setStaticReferenceType (STATIC_TYPES .get ("BatchingSettings" ))
1420
- .setMethodName ("newBuilder" )
1421
- .build ();
1422
- newBatchingSettingsExpr =
1423
- MethodInvocationExpr .builder ()
1424
- .setExprReferenceExpr (newBatchingSettingsExpr )
1425
- .setMethodName ("build" )
1426
- .build ();
1427
-
1428
- String batchingDescVarName =
1429
- String .format (
1430
- BATCHING_DESC_PATTERN , JavaStyle .toUpperSnakeCase (methodName ));
1431
- Expr batchingSettingsBuilderExpr =
1432
- MethodInvocationExpr .builder ()
1433
- .setStaticReferenceType (builderToCallSettingsFn .apply (varType ))
1434
- .setMethodName ("newBuilder" )
1435
- .setArguments (
1436
- VariableExpr .withVariable (
1437
- Variable .builder ()
1438
- .setType (STATIC_TYPES .get ("BatchingDescriptor" ))
1439
- .setName (batchingDescVarName )
1440
- .build ()))
1441
- .build ();
1442
- batchingSettingsBuilderExpr =
1443
- MethodInvocationExpr .builder ()
1444
- .setExprReferenceExpr (batchingSettingsBuilderExpr )
1445
- .setMethodName ("setBatchingSettings" )
1446
- .setArguments (newBatchingSettingsExpr )
1447
- .setReturnType (varType )
1448
- .build ();
1449
-
1351
+ boolean isUnaryCallSettings = isUnaryCallSettingsBuilderFn .apply (varType );
1450
1352
Expr builderExpr =
1451
1353
AssignmentExpr .builder ()
1452
1354
.setVariableExpr (varExpr )
1453
- .setValueExpr (batchingSettingsBuilderExpr )
1355
+ .setValueExpr (
1356
+ MethodInvocationExpr .builder ()
1357
+ .setStaticReferenceType (
1358
+ builderToCallSettingsFn .apply (varExpr .type ()))
1359
+ .setMethodName (
1360
+ isUnaryCallSettings
1361
+ ? "newUnaryCallSettingsBuilder"
1362
+ : "newBuilder" )
1363
+ .setReturnType (varExpr .type ())
1364
+ .build ())
1454
1365
.build ();
1455
1366
return ExprStatement .withExpr (builderExpr );
1456
1367
}
@@ -1496,8 +1407,7 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
1496
1407
.filter (
1497
1408
v ->
1498
1409
isUnaryCallSettingsBuilderFn .apply (v .type ())
1499
- || isPagedCallSettingsBuilderFn .apply (v .type ())
1500
- || isBatchingCallSettingsBuilderFn .apply (v .type ()))
1410
+ || isPagedCallSettingsBuilderFn .apply (v .type ()))
1501
1411
.collect (Collectors .toList ()))
1502
1412
.setReturnType (NESTED_UNARY_METHOD_SETTINGS_BUILDERS_VAR_EXPR .type ())
1503
1413
.build ())
@@ -1779,15 +1689,10 @@ private static Map<String, TypeNode> createStaticTypes() {
1779
1689
ApiClientHeaderProvider .class ,
1780
1690
ApiFunction .class ,
1781
1691
ApiFuture .class ,
1782
- BatchedRequestIssuer .class ,
1783
- BatchingCallSettings .class ,
1784
- BatchingDescriptor .class ,
1785
- BatchingSettings .class ,
1786
1692
BetaApi .class ,
1787
1693
ClientContext .class ,
1788
1694
Duration .class ,
1789
1695
Empty .class ,
1790
- FlowControlSettings .class ,
1791
1696
GaxGrpcProperties .class ,
1792
1697
GaxProperties .class ,
1793
1698
Generated .class ,
@@ -1799,7 +1704,6 @@ private static Map<String, TypeNode> createStaticTypes() {
1799
1704
ImmutableSet .class ,
1800
1705
InstantiatingExecutorProvider .class ,
1801
1706
InstantiatingGrpcChannelProvider .class ,
1802
- LimitExceededBehavior .class ,
1803
1707
List .class ,
1804
1708
Lists .class ,
1805
1709
MonitoredResourceDescriptor .class ,
@@ -1811,9 +1715,7 @@ private static Map<String, TypeNode> createStaticTypes() {
1811
1715
PagedCallSettings .class ,
1812
1716
PagedListDescriptor .class ,
1813
1717
PagedListResponseFactory .class ,
1814
- PartitionKey .class ,
1815
1718
ProtoOperationTransformers .class ,
1816
- RequestBuilder .class ,
1817
1719
RetrySettings .class ,
1818
1720
ServerStreamingCallSettings .class ,
1819
1721
StatusCode .class ,
@@ -1969,10 +1871,7 @@ private static String getGrpcServiceStubTypeName(String serviceName) {
1969
1871
}
1970
1872
1971
1873
private static TypeNode getCallSettingsType (
1972
- Method method ,
1973
- Map <String , TypeNode > types ,
1974
- boolean isBatchingSettings ,
1975
- final boolean isSettingsBuilder ) {
1874
+ Method method , Map <String , TypeNode > types , final boolean isSettingsBuilder ) {
1976
1875
Function <Class , TypeNode > typeMakerFn =
1977
1876
clz -> TypeNode .withReference (ConcreteReference .withClazz (clz ));
1978
1877
// Default: No streaming.
@@ -1982,11 +1881,6 @@ private static TypeNode getCallSettingsType(
1982
1881
isSettingsBuilder ? PagedCallSettings .Builder .class : PagedCallSettings .class )
1983
1882
: typeMakerFn .apply (
1984
1883
isSettingsBuilder ? UnaryCallSettings .Builder .class : UnaryCallSettings .class );
1985
- if (isBatchingSettings ) {
1986
- callSettingsType =
1987
- typeMakerFn .apply (
1988
- isSettingsBuilder ? BatchingCallSettings .Builder .class : BatchingCallSettings .class );
1989
- }
1990
1884
1991
1885
// Streaming takes precendence over paging, as per the monolith's existing behavior.
1992
1886
switch (method .stream ()) {
0 commit comments