-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathhttp_poll.py
More file actions
40 lines (34 loc) · 1.57 KB
/
Copy pathhttp_poll.py
File metadata and controls
40 lines (34 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import asyncio
import uuid
from conductor.asyncio_client.adapters import ApiClient
from conductor.asyncio_client.configuration import Configuration
from conductor.asyncio_client.orkes.orkes_clients import OrkesClients
from conductor.asyncio_client.workflow.conductor_workflow import AsyncConductorWorkflow
from conductor.asyncio_client.workflow.task.http_poll_task import HttpPollTask
from conductor.shared.workflow.models import HttpPollInput
async def main():
configuration = Configuration()
configuration.apply_logging_config()
async with ApiClient(configuration) as api_client:
workflow_executor = OrkesClients(api_client).get_workflow_executor()
workflow = AsyncConductorWorkflow(
executor=workflow_executor, name="http_poll_example_" + str(uuid.uuid4())
)
http_poll = HttpPollTask(
task_ref_name="http_poll_ref",
http_input=HttpPollInput(
uri="https://orkes-api-tester.orkesconductor.com/api",
polling_strategy="EXPONENTIAL_BACKOFF",
polling_interval=5,
termination_condition="(function(){ return $.output.response.body.randomInt < 5000;})();",
),
)
workflow >> http_poll
# execute the workflow to get the results
result = await workflow.execute(workflow_input={}, wait_for_seconds=10)
print(f"Started workflow with id {result.workflow_id}")
print(
f"See the workflow execution: {configuration.ui_host}/execution/{result.workflow_id}\n"
)
if __name__ == "__main__":
asyncio.run(main())