/** Returns true if this method has batching configured. */ public boolean isBatching() { return getBatching() != null; }
private List<BatchingPartitionKeyView> generatePartitionKeys(MethodContext context) { List<BatchingPartitionKeyView> keys = new ArrayList<>(); BatchingConfig batching = context.getMethodConfig().getBatching(); for (GenericFieldSelector fieldSelector : batching.getDiscriminatorFields()) { FieldModel selectedType = fieldSelector.getLastField(); BatchingPartitionKeyView key = BatchingPartitionKeyView.newBuilder() .fieldGetFunction(context.getNamer().getFieldGetFunctionName(selectedType)) .build(); keys.add(key); } return keys; } }
public List<BatchingDescriptorView> generateDescriptors(InterfaceContext context) { SurfaceNamer namer = context.getNamer(); ImmutableList.Builder<BatchingDescriptorView> descriptors = ImmutableList.builder(); for (MethodModel method : context.getBatchingMethods()) { BatchingConfig batching = context.getMethodConfig(method).getBatching(); BatchingDescriptorView.Builder descriptor = BatchingDescriptorView.newBuilder(); descriptor.methodName(context.getNamer().getMethodKey(method)); descriptor.batchedFieldName(namer.getFieldName(batching.getBatchedField())); descriptor.discriminatorFieldNames(generateDiscriminatorFieldNames(batching)); if (batching.hasSubresponseField()) { descriptor.subresponseFieldName(namer.getFieldName(batching.getSubresponseField())); } descriptor.byteLengthFunctionName( namer.getByteLengthFunctionName(batching.getBatchedField())); descriptors.add(descriptor.build()); } return descriptors.build(); }
public BatchingConfigView generateBatchingConfig(MethodContext context) { BatchingConfig batchingConfig = context.getMethodConfig().getBatching(); BatchingConfigView.Builder batchingConfigView = BatchingConfigView.newBuilder(); batchingConfigView.elementCountThreshold(batchingConfig.getElementCountThreshold()); batchingConfigView.requestByteThreshold(batchingConfig.getRequestByteThreshold()); batchingConfigView.delayThresholdMillis(batchingConfig.getDelayThresholdMillis()); batchingConfigView.flowControlElementLimit(batchingConfig.getFlowControlElementLimit()); batchingConfigView.flowControlByteLimit(batchingConfig.getFlowControlByteLimit()); batchingConfigView.flowControlLimitExceededBehavior( batchingConfig.getFlowControlLimitConfig().toString()); return batchingConfigView.build(); }
BatchingConfig config = context.getMethodConfig().getBatching(); if (config.getSubresponseField() != null) { String subResponseFieldName = config.getSubresponseField().getSimpleName();
private BatchingDescriptorClassView generateDescriptorClass(MethodContext context) { SurfaceNamer namer = context.getNamer(); MethodModel method = context.getMethodModel(); BatchingConfig batching = context.getMethodConfig().getBatching(); FieldModel batchedField = batching.getBatchedField(); FieldModel subresponseField = batching.getSubresponseField(); BatchingDescriptorClassView.Builder desc = BatchingDescriptorClassView.newBuilder(); desc.name(context.getNamer().getBatchingDescriptorConstName(context.getMethodModel())); desc.requestTypeName( method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer())); desc.responseTypeName( method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer())); desc.partitionKeys(generatePartitionKeys(context)); desc.batchedFieldGetFunction(namer.getFieldGetFunctionName(batchedField)); desc.batchedFieldSetFunction(namer.getFieldSetFunctionName(batchedField)); desc.batchedFieldCountGetFunction(namer.getFieldCountGetFunctionName(batchedField)); if (subresponseField != null) { desc.subresponseTypeName(context.getTypeTable().getAndSaveNicknameFor(subresponseField)); desc.subresponseByIndexGetFunction(namer.getByIndexGetFunctionName(subresponseField)); desc.subresponseSetFunction(namer.getFieldSetFunctionName(subresponseField)); } return desc.build(); }