1818import com .google .api .core .ApiFunction ;
1919import com .google .api .core .ApiFuture ;
2020import 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 ;
2621import com .google .api .gax .core .GaxProperties ;
2722import com .google .api .gax .core .GoogleCredentialsProvider ;
2823import com .google .api .gax .core .InstantiatingExecutorProvider ;
3530import com .google .api .gax .retrying .RetrySettings ;
3631import com .google .api .gax .rpc .ApiCallContext ;
3732import 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 ;
4133import com .google .api .gax .rpc .ClientContext ;
4234import com .google .api .gax .rpc .OperationCallSettings ;
4335import com .google .api .gax .rpc .PageContext ;
8274import com .google .api .generator .engine .ast .Variable ;
8375import com .google .api .generator .engine .ast .VariableExpr ;
8476import com .google .api .generator .gapic .model .Field ;
85- import com .google .api .generator .gapic .model .GapicBatchingSettings ;
8677import com .google .api .generator .gapic .model .GapicClass ;
8778import com .google .api .generator .gapic .model .GapicServiceConfig ;
8879import com .google .api .generator .gapic .model .Message ;
@@ -221,12 +212,8 @@ private static Map<String, VariableExpr> createMethodSettingsClassMemberVarExprs
221212 Map <String , VariableExpr > varExprs = new LinkedHashMap <>();
222213
223214 // Creates class variables <method>Settings, e.g. echoSettings.
224- // TODO(miraleung): Handle batching here.
225215 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 );
230217 String varName = JavaStyle .toLowerCamelCase (String .format ("%sSettings" , method .name ()));
231218 varExprs .put (
232219 varName ,
@@ -313,20 +300,6 @@ private static List<Statement> createClassStatements(
313300 statements .add (EMPTY_LINE_STATEMENT );
314301 }
315302
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-
330303 return statements ;
331304 }
332305
@@ -1261,22 +1234,6 @@ private static MethodDefinition createNestedClassInitDefaultsMethod(
12611234 if (streamKind .equals (Method .Stream .CLIENT ) || streamKind .equals (Method .Stream .BIDI )) {
12621235 continue ;
12631236 }
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- }
12801237
12811238 bodyStatements .add (
12821239 ExprStatement .withExpr (
@@ -1352,8 +1309,6 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
13521309 .build ());
13531310 Reference pagedSettingsBuilderRef =
13541311 ConcreteReference .withClazz (PagedCallSettings .Builder .class );
1355- Reference batchingSettingsBuilderRef =
1356- ConcreteReference .withClazz (BatchingCallSettings .Builder .class );
13571312 Reference unaryCallSettingsBuilderRef =
13581313 ConcreteReference .withClazz (UnaryCallSettings .Builder .class );
13591314 Function <TypeNode , Boolean > isUnaryCallSettingsBuilderFn =
@@ -1363,9 +1318,6 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
13631318 .equals (unaryCallSettingsBuilderRef );
13641319 Function <TypeNode , Boolean > isPagedCallSettingsBuilderFn =
13651320 t -> t .reference ().copyAndSetGenerics (ImmutableList .of ()).equals (pagedSettingsBuilderRef );
1366- Function <TypeNode , Boolean > isBatchingCallSettingsBuilderFn =
1367- t ->
1368- t .reference ().copyAndSetGenerics (ImmutableList .of ()).equals (batchingSettingsBuilderRef );
13691321 Function <TypeNode , TypeNode > builderToCallSettingsFn =
13701322 t ->
13711323 TypeNode .withReference (
@@ -1396,61 +1348,20 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
13961348 String methodName = getMethodNameFromSettingsVarName (e .getKey ());
13971349
13981350 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 );
14501352 Expr builderExpr =
14511353 AssignmentExpr .builder ()
14521354 .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 ())
14541365 .build ();
14551366 return ExprStatement .withExpr (builderExpr );
14561367 }
@@ -1496,8 +1407,7 @@ private static List<MethodDefinition> createNestedClassConstructorMethods(
14961407 .filter (
14971408 v ->
14981409 isUnaryCallSettingsBuilderFn .apply (v .type ())
1499- || isPagedCallSettingsBuilderFn .apply (v .type ())
1500- || isBatchingCallSettingsBuilderFn .apply (v .type ()))
1410+ || isPagedCallSettingsBuilderFn .apply (v .type ()))
15011411 .collect (Collectors .toList ()))
15021412 .setReturnType (NESTED_UNARY_METHOD_SETTINGS_BUILDERS_VAR_EXPR .type ())
15031413 .build ())
@@ -1779,15 +1689,10 @@ private static Map<String, TypeNode> createStaticTypes() {
17791689 ApiClientHeaderProvider .class ,
17801690 ApiFunction .class ,
17811691 ApiFuture .class ,
1782- BatchedRequestIssuer .class ,
1783- BatchingCallSettings .class ,
1784- BatchingDescriptor .class ,
1785- BatchingSettings .class ,
17861692 BetaApi .class ,
17871693 ClientContext .class ,
17881694 Duration .class ,
17891695 Empty .class ,
1790- FlowControlSettings .class ,
17911696 GaxGrpcProperties .class ,
17921697 GaxProperties .class ,
17931698 Generated .class ,
@@ -1799,7 +1704,6 @@ private static Map<String, TypeNode> createStaticTypes() {
17991704 ImmutableSet .class ,
18001705 InstantiatingExecutorProvider .class ,
18011706 InstantiatingGrpcChannelProvider .class ,
1802- LimitExceededBehavior .class ,
18031707 List .class ,
18041708 Lists .class ,
18051709 MonitoredResourceDescriptor .class ,
@@ -1811,9 +1715,7 @@ private static Map<String, TypeNode> createStaticTypes() {
18111715 PagedCallSettings .class ,
18121716 PagedListDescriptor .class ,
18131717 PagedListResponseFactory .class ,
1814- PartitionKey .class ,
18151718 ProtoOperationTransformers .class ,
1816- RequestBuilder .class ,
18171719 RetrySettings .class ,
18181720 ServerStreamingCallSettings .class ,
18191721 StatusCode .class ,
@@ -1969,10 +1871,7 @@ private static String getGrpcServiceStubTypeName(String serviceName) {
19691871 }
19701872
19711873 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 ) {
19761875 Function <Class , TypeNode > typeMakerFn =
19771876 clz -> TypeNode .withReference (ConcreteReference .withClazz (clz ));
19781877 // Default: No streaming.
@@ -1982,11 +1881,6 @@ private static TypeNode getCallSettingsType(
19821881 isSettingsBuilder ? PagedCallSettings .Builder .class : PagedCallSettings .class )
19831882 : typeMakerFn .apply (
19841883 isSettingsBuilder ? UnaryCallSettings .Builder .class : UnaryCallSettings .class );
1985- if (isBatchingSettings ) {
1986- callSettingsType =
1987- typeMakerFn .apply (
1988- isSettingsBuilder ? BatchingCallSettings .Builder .class : BatchingCallSettings .class );
1989- }
19901884
19911885 // Streaming takes precendence over paging, as per the monolith's existing behavior.
19921886 switch (method .stream ()) {
0 commit comments