-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
183 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import uuid | ||
|
||
from conductor.client.orkes_clients import OrkesClients | ||
from conductor.client.workflow.conductor_workflow import ConductorWorkflow | ||
from conductor.client.workflow.task.http_poll_task import HttpPollTask, HttpPollInput | ||
|
||
|
||
def main(): | ||
workflow_executor = OrkesClients().get_workflow_executor() | ||
workflow = ConductorWorkflow(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=1000, | ||
termination_condition='(function(){ return $.output.response.body.randomInt < 10;})();'), | ||
) | ||
workflow >> http_poll | ||
|
||
# execute the workflow to get the results | ||
result = workflow.execute(workflow_input={}, wait_for_seconds=10) | ||
print(f'result: {result.output}') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from copy import deepcopy | ||
from enum import Enum | ||
from typing import Any, Dict, List, Union | ||
|
||
from typing_extensions import Self | ||
|
||
from conductor.client.workflow.task.http_task import HttpTask, HttpInput, HttpMethod | ||
from conductor.client.workflow.task.task import TaskInterface | ||
from conductor.client.workflow.task.task_type import TaskType | ||
|
||
|
||
class HttpPollInput(): | ||
swagger_types = { | ||
'_uri': 'str', | ||
'_method': 'str', | ||
'_accept': 'list[str]', | ||
'_headers': 'dict[str, list[str]]', | ||
'_content_type': 'str', | ||
'_connection_time_out': 'int', | ||
'_read_timeout': 'int', | ||
'_body': 'str', | ||
'_termination_condition': 'str', | ||
'_polling_interval': 'int', | ||
'_max_poll_count': 'int', | ||
'_polling_strategy': str | ||
} | ||
|
||
attribute_map = { | ||
'_uri': 'uri', | ||
'_method': 'method', | ||
'_accept': 'accept', | ||
'_headers': 'headers', | ||
'_content_type': 'contentType', | ||
'_connection_time_out': 'connectionTimeOut', | ||
'_read_timeout': 'readTimeOut', | ||
'_body': 'body', | ||
'_termination_condition': 'terminationCondition', | ||
'_polling_interval': 'pollingInterval', | ||
'_max_poll_count': 'maxPollCount', | ||
'_polling_strategy': 'pollingStrategy' | ||
} | ||
|
||
def __init__(self, | ||
termination_condition: str = None, | ||
max_poll_count : int = 100, | ||
polling_interval : int = 100, | ||
polling_strategy: str = 'FIXED', | ||
method: HttpMethod = HttpMethod.GET, | ||
uri: str = None, | ||
headers: Dict[str, List[str]] = None, | ||
accept: str = None, | ||
content_type: str = None, | ||
connection_time_out: int = None, | ||
read_timeout: int = None, | ||
body: Any = None) -> Self: | ||
self._method = deepcopy(method) | ||
self._uri = deepcopy(uri) | ||
self._headers = deepcopy(headers) | ||
self._accept = deepcopy(accept) | ||
self._content_type = deepcopy(content_type) | ||
self._connection_time_out = deepcopy(connection_time_out) | ||
self._read_timeout = deepcopy(read_timeout) | ||
self._body = deepcopy(body) | ||
self._termination_condition = termination_condition | ||
self._max_poll_count = max_poll_count | ||
self._polling_interval = polling_interval | ||
self._polling_strategy = polling_strategy | ||
|
||
|
||
class HttpPollTask(TaskInterface): | ||
def __init__(self, task_ref_name: str, http_input: HttpPollInput) -> Self: | ||
super().__init__( | ||
task_reference_name=task_ref_name, | ||
task_type=TaskType.HTTP_POLL, | ||
input_parameters={'http_request': http_input} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters