Ejemplo n.º 1
0
        "public_metrics",
        "text",
    ],
    user_fields=["id", "name", "public_metrics", "username", "verified"],
    expansions=["author_id"],
    place_fields=None,
    max_tweets=10,
)

# Create instance of workflow, adding observer config to it, it will autgenerate unique workflow id
workflow = Workflow(
    config=WorkflowConfig(
        source_config=source_config,
    ),
)
# Insert workflow config to DB store
store.add_workflow(workflow)

for i in range(1, 4):
    print_state(workflow.id)
    # Now always pass workflow id to lookup function
    # Observer will fetch old data from DB suing this id and later store new updated state data against this id to DB 
    source_response_list = source.lookup(source_config, id=workflow.id)

    if source_response_list is None or len(source_response_list) == 0:
        break

    time.sleep(180)

print_state(workflow.id)
Ejemplo n.º 2
0
```
     {%- for key, value in payload.items() recursive%}
         {%- if value is mapping -%}
{{loop(value.items())}}
         {%- else %}
{{key}}: {{value}}
         {%- endif %}
     {%- endfor%}
```
   """)
sink = SlackSink(store=workflow_store)

analyzer_config = DummyAnalyzerConfig()
analyzer = DummyAnalyzer()

workflow = Workflow(config=WorkflowConfig(
    source_config=source_config,
    sink_config=sink_config,
    analyzer_config=analyzer_config,
), )
workflow_store.add_workflow(workflow)

processor = Processor(analyzer=analyzer,
                      sink=sink,
                      source=source,
                      analyzer_config=analyzer_config)

processor.process(workflow=workflow)

print_state(workflow.id)