29 lines
887 B
Python
29 lines
887 B
Python
from temporalio import workflow
|
|
|
|
with workflow.unsafe.imports_passed_through():
|
|
from scouter.activities.faker import Faker
|
|
from datetime import timedelta
|
|
from typing import Dict, Any
|
|
from scouter.utils.policies import retry_policy
|
|
|
|
|
|
@workflow.defn(name="fake_data")
|
|
class FakeData:
|
|
@workflow.run
|
|
async def run(self, workflow_input: Dict[str, Any]) -> str:
|
|
"""
|
|
Generates random data and sends it to a Kafka topic.
|
|
|
|
Args:
|
|
workflow_input (dict[str, Any]): The input data containing:
|
|
topic (str): The Kafka topic to send data to
|
|
"""
|
|
await workflow.execute_activity_method(
|
|
Faker.generate_and_send_data,
|
|
{
|
|
'topic': workflow_input['topic']
|
|
},
|
|
retry_policy=retry_policy,
|
|
start_to_close_timeout=timedelta(seconds=60)
|
|
)
|