如何在客户Python处理器中指定读取器服务PropertyDefinition?

问题描述 投票:0回答:1

我创建了一个最小的 python 示例来设置读者服务属性定义:

from nifiapi.properties import PropertyDescriptor
from nifiapi.flowfiletransform import FlowFileTransform, FlowFileTransformResult

class PythonReaderServiceExample(FlowFileTransform):
    class Java:
        implements = ['org.apache.nifi.python.processor.FlowFileTransform']

    class ProcessorDetails:
        dependencies = []
        version = '0.0.1-SNAPSHOT'

    def __init__(self, **kwargs):
  
        self.RECORD_READER = PropertyDescriptor(
                                name="Record Reader", 
                                description="Specifies the Controller Service to use for parsing incoming data into Records.",
                                required=True,
                                allowable_values=["- create new service -"],
                                controller_service_definition="org.apache.nifi.serialization.RecordReaderFactory")

        self.descriptors = [self.RECORD_READER] 

    def getPropertyDescriptors(self):
        return self.descriptors
 
    def transform(self, context, flowFile):
        return FlowFileTransformResult(relationship = "success")

我看到创建新读者服务的选项:

Create service

当我添加服务时,我看到以下内容:

enter image description here

我的目标是能够设置 Reader Service 并能够导航到它等,按照此 PutAzureCosmosDBRecord 示例:

enter image description here

我的 Python 代码中还需要包含什么?

python-3.x apache-nifi
1个回答
0
投票

似乎只需删除 allowed_values 属性定义就足以解决此问题。

allowable_values=["- create new service -"],
© www.soinside.com 2019 - 2024. All rights reserved.