azure-functions-durable 1.2.8__py3-none-any.whl → 1.2.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/durable_functions/__init__.py +81 -81
- azure/durable_functions/constants.py +9 -9
- azure/durable_functions/decorators/__init__.py +3 -3
- azure/durable_functions/decorators/durable_app.py +249 -249
- azure/durable_functions/decorators/metadata.py +109 -109
- azure/durable_functions/entity.py +125 -125
- azure/durable_functions/models/DurableEntityContext.py +201 -201
- azure/durable_functions/models/DurableHttpRequest.py +58 -58
- azure/durable_functions/models/DurableOrchestrationBindings.py +66 -66
- azure/durable_functions/models/DurableOrchestrationClient.py +781 -711
- azure/durable_functions/models/DurableOrchestrationContext.py +722 -707
- azure/durable_functions/models/DurableOrchestrationStatus.py +156 -156
- azure/durable_functions/models/EntityStateResponse.py +23 -23
- azure/durable_functions/models/FunctionContext.py +7 -7
- azure/durable_functions/models/OrchestrationRuntimeStatus.py +32 -29
- azure/durable_functions/models/OrchestratorState.py +117 -116
- azure/durable_functions/models/PurgeHistoryResult.py +33 -33
- azure/durable_functions/models/ReplaySchema.py +8 -8
- azure/durable_functions/models/RetryOptions.py +69 -69
- azure/durable_functions/models/RpcManagementOptions.py +86 -86
- azure/durable_functions/models/Task.py +426 -426
- azure/durable_functions/models/TaskOrchestrationExecutor.py +346 -333
- azure/durable_functions/models/TokenSource.py +56 -56
- azure/durable_functions/models/__init__.py +24 -24
- azure/durable_functions/models/actions/Action.py +23 -23
- azure/durable_functions/models/actions/ActionType.py +18 -18
- azure/durable_functions/models/actions/CallActivityAction.py +41 -41
- azure/durable_functions/models/actions/CallActivityWithRetryAction.py +45 -45
- azure/durable_functions/models/actions/CallEntityAction.py +46 -46
- azure/durable_functions/models/actions/CallHttpAction.py +35 -35
- azure/durable_functions/models/actions/CallSubOrchestratorAction.py +40 -40
- azure/durable_functions/models/actions/CallSubOrchestratorWithRetryAction.py +44 -44
- azure/durable_functions/models/actions/CompoundAction.py +35 -35
- azure/durable_functions/models/actions/ContinueAsNewAction.py +36 -36
- azure/durable_functions/models/actions/CreateTimerAction.py +48 -48
- azure/durable_functions/models/actions/NoOpAction.py +35 -35
- azure/durable_functions/models/actions/SignalEntityAction.py +47 -47
- azure/durable_functions/models/actions/WaitForExternalEventAction.py +63 -63
- azure/durable_functions/models/actions/WhenAllAction.py +14 -14
- azure/durable_functions/models/actions/WhenAnyAction.py +14 -14
- azure/durable_functions/models/actions/__init__.py +24 -24
- azure/durable_functions/models/entities/EntityState.py +74 -74
- azure/durable_functions/models/entities/OperationResult.py +76 -76
- azure/durable_functions/models/entities/RequestMessage.py +53 -53
- azure/durable_functions/models/entities/ResponseMessage.py +48 -48
- azure/durable_functions/models/entities/Signal.py +62 -62
- azure/durable_functions/models/entities/__init__.py +17 -17
- azure/durable_functions/models/history/HistoryEvent.py +92 -92
- azure/durable_functions/models/history/HistoryEventType.py +27 -25
- azure/durable_functions/models/history/__init__.py +8 -8
- azure/durable_functions/models/utils/__init__.py +7 -7
- azure/durable_functions/models/utils/entity_utils.py +103 -91
- azure/durable_functions/models/utils/http_utils.py +69 -69
- azure/durable_functions/models/utils/json_utils.py +56 -56
- azure/durable_functions/orchestrator.py +71 -71
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/LICENSE +21 -21
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/METADATA +58 -58
- azure_functions_durable-1.2.10.dist-info/RECORD +100 -0
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/WHEEL +1 -1
- tests/models/test_DecoratorMetadata.py +135 -135
- tests/models/test_Decorators.py +107 -107
- tests/models/test_DurableOrchestrationBindings.py +68 -56
- tests/models/test_DurableOrchestrationClient.py +730 -612
- tests/models/test_DurableOrchestrationContext.py +102 -102
- tests/models/test_DurableOrchestrationStatus.py +59 -59
- tests/models/test_OrchestrationState.py +28 -28
- tests/models/test_RpcManagementOptions.py +79 -79
- tests/models/test_TokenSource.py +10 -10
- tests/orchestrator/models/OrchestrationInstance.py +18 -18
- tests/orchestrator/orchestrator_test_utils.py +130 -130
- tests/orchestrator/schemas/OrchetrationStateSchema.py +66 -66
- tests/orchestrator/test_call_http.py +235 -176
- tests/orchestrator/test_continue_as_new.py +67 -67
- tests/orchestrator/test_create_timer.py +126 -126
- tests/orchestrator/test_entity.py +395 -395
- tests/orchestrator/test_external_event.py +53 -53
- tests/orchestrator/test_fan_out_fan_in.py +175 -175
- tests/orchestrator/test_is_replaying_flag.py +101 -101
- tests/orchestrator/test_retries.py +308 -308
- tests/orchestrator/test_sequential_orchestrator.py +841 -801
- tests/orchestrator/test_sequential_orchestrator_custom_status.py +119 -119
- tests/orchestrator/test_sequential_orchestrator_with_retry.py +465 -465
- tests/orchestrator/test_serialization.py +30 -30
- tests/orchestrator/test_sub_orchestrator.py +95 -95
- tests/orchestrator/test_sub_orchestrator_with_retry.py +129 -129
- tests/orchestrator/test_task_any.py +60 -60
- tests/tasks/tasks_test_utils.py +17 -17
- tests/tasks/test_new_uuid.py +34 -34
- tests/test_utils/ContextBuilder.py +174 -174
- tests/test_utils/EntityContextBuilder.py +56 -56
- tests/test_utils/constants.py +1 -1
- tests/test_utils/json_utils.py +30 -30
- tests/test_utils/testClasses.py +56 -56
- tests/utils/__init__.py +1 -0
- tests/utils/test_entity_utils.py +24 -0
- azure_functions_durable-1.2.8.data/data/_manifest/bsi.json +0 -1
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.cat +0 -0
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.spdx.json +0 -12845
- azure_functions_durable-1.2.8.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
- azure_functions_durable-1.2.8.dist-info/RECORD +0 -102
- {azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/top_level.txt +0 -0
|
@@ -1,91 +1,103 @@
|
|
|
1
|
-
class EntityId:
|
|
2
|
-
"""EntityId.
|
|
3
|
-
|
|
4
|
-
It identifies an entity by its name and its key.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
def __init__(self, name: str, key: str):
|
|
8
|
-
"""Instantiate an EntityId object.
|
|
9
|
-
|
|
10
|
-
Identifies an entity by its name and its key.
|
|
11
|
-
|
|
12
|
-
Parameters
|
|
13
|
-
----------
|
|
14
|
-
name: str
|
|
15
|
-
The entity name
|
|
16
|
-
key: str
|
|
17
|
-
The entity key
|
|
18
|
-
|
|
19
|
-
Raises
|
|
20
|
-
------
|
|
21
|
-
ValueError: If the entity name or key are the empty string
|
|
22
|
-
"""
|
|
23
|
-
if name == "":
|
|
24
|
-
raise ValueError("Entity name cannot be empty")
|
|
25
|
-
if key == "":
|
|
26
|
-
raise ValueError("Entity key cannot be empty")
|
|
27
|
-
self.name: str = name
|
|
28
|
-
self.key: str = key
|
|
29
|
-
|
|
30
|
-
@staticmethod
|
|
31
|
-
def get_scheduler_id(entity_id: 'EntityId') -> str:
|
|
32
|
-
"""Produce a SchedulerId from an EntityId.
|
|
33
|
-
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
entity_id: EntityId
|
|
37
|
-
An EntityId object
|
|
38
|
-
|
|
39
|
-
Returns
|
|
40
|
-
-------
|
|
41
|
-
str:
|
|
42
|
-
A SchedulerId representation of the input EntityId
|
|
43
|
-
"""
|
|
44
|
-
return f"@{entity_id.name.lower()}@{entity_id.key}"
|
|
45
|
-
|
|
46
|
-
@staticmethod
|
|
47
|
-
def get_entity_id(scheduler_id: str) -> 'EntityId':
|
|
48
|
-
"""Return an EntityId from a SchedulerId string.
|
|
49
|
-
|
|
50
|
-
Parameters
|
|
51
|
-
----------
|
|
52
|
-
scheduler_id: str
|
|
53
|
-
The SchedulerId in which to base the returned EntityId
|
|
54
|
-
|
|
55
|
-
Raises
|
|
56
|
-
------
|
|
57
|
-
ValueError:
|
|
58
|
-
When the SchedulerId string does not have the expected format
|
|
59
|
-
|
|
60
|
-
Returns
|
|
61
|
-
-------
|
|
62
|
-
EntityId:
|
|
63
|
-
An EntityId object based on the SchedulerId string
|
|
64
|
-
"""
|
|
65
|
-
sched_id_truncated = scheduler_id[1:] # we drop the starting `@`
|
|
66
|
-
components = sched_id_truncated.split("@")
|
|
67
|
-
if len(components) != 2:
|
|
68
|
-
raise ValueError("Unexpected format in SchedulerId")
|
|
69
|
-
[name, key] = components
|
|
70
|
-
return EntityId(name, key)
|
|
71
|
-
|
|
72
|
-
@staticmethod
|
|
73
|
-
def get_entity_id_url_path(entity_id: 'EntityId') -> str:
|
|
74
|
-
"""Print the the entity url path.
|
|
75
|
-
|
|
76
|
-
Returns
|
|
77
|
-
-------
|
|
78
|
-
str:
|
|
79
|
-
A url path of the EntityId
|
|
80
|
-
"""
|
|
81
|
-
return f'entities/{entity_id.name}/{entity_id.key}'
|
|
82
|
-
|
|
83
|
-
def __str__(self) -> str:
|
|
84
|
-
"""Print the string representation of this EntityId.
|
|
85
|
-
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
str:
|
|
89
|
-
A SchedulerId-based string representation of the EntityId
|
|
90
|
-
"""
|
|
91
|
-
return EntityId.get_scheduler_id(entity_id=self)
|
|
1
|
+
class EntityId:
|
|
2
|
+
"""EntityId.
|
|
3
|
+
|
|
4
|
+
It identifies an entity by its name and its key.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
def __init__(self, name: str, key: str):
|
|
8
|
+
"""Instantiate an EntityId object.
|
|
9
|
+
|
|
10
|
+
Identifies an entity by its name and its key.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
name: str
|
|
15
|
+
The entity name
|
|
16
|
+
key: str
|
|
17
|
+
The entity key
|
|
18
|
+
|
|
19
|
+
Raises
|
|
20
|
+
------
|
|
21
|
+
ValueError: If the entity name or key are the empty string
|
|
22
|
+
"""
|
|
23
|
+
if name == "":
|
|
24
|
+
raise ValueError("Entity name cannot be empty")
|
|
25
|
+
if key == "":
|
|
26
|
+
raise ValueError("Entity key cannot be empty")
|
|
27
|
+
self.name: str = name
|
|
28
|
+
self.key: str = key
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def get_scheduler_id(entity_id: 'EntityId') -> str:
|
|
32
|
+
"""Produce a SchedulerId from an EntityId.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
entity_id: EntityId
|
|
37
|
+
An EntityId object
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
str:
|
|
42
|
+
A SchedulerId representation of the input EntityId
|
|
43
|
+
"""
|
|
44
|
+
return f"@{entity_id.name.lower()}@{entity_id.key}"
|
|
45
|
+
|
|
46
|
+
@staticmethod
|
|
47
|
+
def get_entity_id(scheduler_id: str) -> 'EntityId':
|
|
48
|
+
"""Return an EntityId from a SchedulerId string.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
scheduler_id: str
|
|
53
|
+
The SchedulerId in which to base the returned EntityId
|
|
54
|
+
|
|
55
|
+
Raises
|
|
56
|
+
------
|
|
57
|
+
ValueError:
|
|
58
|
+
When the SchedulerId string does not have the expected format
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
EntityId:
|
|
63
|
+
An EntityId object based on the SchedulerId string
|
|
64
|
+
"""
|
|
65
|
+
sched_id_truncated = scheduler_id[1:] # we drop the starting `@`
|
|
66
|
+
components = sched_id_truncated.split("@")
|
|
67
|
+
if len(components) != 2:
|
|
68
|
+
raise ValueError("Unexpected format in SchedulerId")
|
|
69
|
+
[name, key] = components
|
|
70
|
+
return EntityId(name, key)
|
|
71
|
+
|
|
72
|
+
@staticmethod
|
|
73
|
+
def get_entity_id_url_path(entity_id: 'EntityId') -> str:
|
|
74
|
+
"""Print the the entity url path.
|
|
75
|
+
|
|
76
|
+
Returns
|
|
77
|
+
-------
|
|
78
|
+
str:
|
|
79
|
+
A url path of the EntityId
|
|
80
|
+
"""
|
|
81
|
+
return f'entities/{entity_id.name}/{entity_id.key}'
|
|
82
|
+
|
|
83
|
+
def __str__(self) -> str:
|
|
84
|
+
"""Print the string representation of this EntityId.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
str:
|
|
89
|
+
A SchedulerId-based string representation of the EntityId
|
|
90
|
+
"""
|
|
91
|
+
return EntityId.get_scheduler_id(entity_id=self)
|
|
92
|
+
|
|
93
|
+
def __eq__(self, other: object) -> bool:
|
|
94
|
+
"""Check if two EntityId objects are equal.
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
other: object
|
|
99
|
+
"""
|
|
100
|
+
if not isinstance(other, EntityId):
|
|
101
|
+
return False
|
|
102
|
+
|
|
103
|
+
return self.name == other.name and self.key == other.key
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
from typing import Any, List, Union
|
|
2
|
-
|
|
3
|
-
import aiohttp
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
async def post_async_request(url: str, data: Any = None) -> List[Union[int, Any]]:
|
|
7
|
-
"""Post request with the data provided to the url provided.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
url: str
|
|
12
|
-
url to make the post to
|
|
13
|
-
data: Any
|
|
14
|
-
object to post
|
|
15
|
-
|
|
16
|
-
Returns
|
|
17
|
-
-------
|
|
18
|
-
[int, Any]
|
|
19
|
-
Tuple with the Response status code and the data returned from the request
|
|
20
|
-
"""
|
|
21
|
-
async with aiohttp.ClientSession() as session:
|
|
22
|
-
async with session.post(url,
|
|
23
|
-
json=data) as response:
|
|
24
|
-
# We disable aiohttp's input type validation
|
|
25
|
-
# as the server may respond with alternative
|
|
26
|
-
# data encodings. This is potentially unsafe.
|
|
27
|
-
# More here: https://docs.aiohttp.org/en/stable/client_advanced.html
|
|
28
|
-
data = await response.json(content_type=None)
|
|
29
|
-
return [response.status, data]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
async def get_async_request(url: str) -> List[Any]:
|
|
33
|
-
"""Get the data from the url provided.
|
|
34
|
-
|
|
35
|
-
Parameters
|
|
36
|
-
----------
|
|
37
|
-
url: str
|
|
38
|
-
url to get the data from
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
[int, Any]
|
|
43
|
-
Tuple with the Response status code and the data returned from the request
|
|
44
|
-
"""
|
|
45
|
-
async with aiohttp.ClientSession() as session:
|
|
46
|
-
async with session.get(url) as response:
|
|
47
|
-
data = await response.json(content_type=None)
|
|
48
|
-
if data is None:
|
|
49
|
-
data = ""
|
|
50
|
-
return [response.status, data]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async def delete_async_request(url: str) -> List[Union[int, Any]]:
|
|
54
|
-
"""Delete the data from the url provided.
|
|
55
|
-
|
|
56
|
-
Parameters
|
|
57
|
-
----------
|
|
58
|
-
url: str
|
|
59
|
-
url to delete the data from
|
|
60
|
-
|
|
61
|
-
Returns
|
|
62
|
-
-------
|
|
63
|
-
[int, Any]
|
|
64
|
-
Tuple with the Response status code and the data returned from the request
|
|
65
|
-
"""
|
|
66
|
-
async with aiohttp.ClientSession() as session:
|
|
67
|
-
async with session.delete(url) as response:
|
|
68
|
-
data = await response.json(content_type=None)
|
|
69
|
-
return [response.status, data]
|
|
1
|
+
from typing import Any, List, Union
|
|
2
|
+
|
|
3
|
+
import aiohttp
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async def post_async_request(url: str, data: Any = None) -> List[Union[int, Any]]:
|
|
7
|
+
"""Post request with the data provided to the url provided.
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
url: str
|
|
12
|
+
url to make the post to
|
|
13
|
+
data: Any
|
|
14
|
+
object to post
|
|
15
|
+
|
|
16
|
+
Returns
|
|
17
|
+
-------
|
|
18
|
+
[int, Any]
|
|
19
|
+
Tuple with the Response status code and the data returned from the request
|
|
20
|
+
"""
|
|
21
|
+
async with aiohttp.ClientSession() as session:
|
|
22
|
+
async with session.post(url,
|
|
23
|
+
json=data) as response:
|
|
24
|
+
# We disable aiohttp's input type validation
|
|
25
|
+
# as the server may respond with alternative
|
|
26
|
+
# data encodings. This is potentially unsafe.
|
|
27
|
+
# More here: https://docs.aiohttp.org/en/stable/client_advanced.html
|
|
28
|
+
data = await response.json(content_type=None)
|
|
29
|
+
return [response.status, data]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
async def get_async_request(url: str) -> List[Any]:
|
|
33
|
+
"""Get the data from the url provided.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
url: str
|
|
38
|
+
url to get the data from
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
[int, Any]
|
|
43
|
+
Tuple with the Response status code and the data returned from the request
|
|
44
|
+
"""
|
|
45
|
+
async with aiohttp.ClientSession() as session:
|
|
46
|
+
async with session.get(url) as response:
|
|
47
|
+
data = await response.json(content_type=None)
|
|
48
|
+
if data is None:
|
|
49
|
+
data = ""
|
|
50
|
+
return [response.status, data]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def delete_async_request(url: str) -> List[Union[int, Any]]:
|
|
54
|
+
"""Delete the data from the url provided.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
url: str
|
|
59
|
+
url to delete the data from
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
[int, Any]
|
|
64
|
+
Tuple with the Response status code and the data returned from the request
|
|
65
|
+
"""
|
|
66
|
+
async with aiohttp.ClientSession() as session:
|
|
67
|
+
async with session.delete(url) as response:
|
|
68
|
+
data = await response.json(content_type=None)
|
|
69
|
+
return [response.status, data]
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
from typing import Dict, Any
|
|
2
|
-
|
|
3
|
-
from ...constants import DATETIME_STRING_FORMAT
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def add_attrib(json_dict: Dict[str, Any], object_,
|
|
7
|
-
attribute_name: str, alt_name: str = None):
|
|
8
|
-
"""Add the value of the attribute from the object to the dictionary.
|
|
9
|
-
|
|
10
|
-
Used to dynamically add the value of the attribute if the value is present.
|
|
11
|
-
|
|
12
|
-
Parameters
|
|
13
|
-
----------
|
|
14
|
-
json_dict: The dictionary to add the attribute to
|
|
15
|
-
object_: The object to look for the attribute on
|
|
16
|
-
attribute_name: The name of the attribute to look for
|
|
17
|
-
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
18
|
-
"""
|
|
19
|
-
if hasattr(object_, attribute_name):
|
|
20
|
-
json_dict[alt_name or attribute_name] = \
|
|
21
|
-
getattr(object_, attribute_name)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def add_datetime_attrib(json_dict: Dict[str, Any], object_,
|
|
25
|
-
attribute_name: str, alt_name: str = None):
|
|
26
|
-
"""Add the value of the attribute from the object to the dictionary converted into a string.
|
|
27
|
-
|
|
28
|
-
Parameters
|
|
29
|
-
----------
|
|
30
|
-
json_dict: The dictionary to add the attribute to
|
|
31
|
-
object_: The object to look for the attribute on
|
|
32
|
-
attribute_name: The name of the attribute to look for
|
|
33
|
-
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
34
|
-
"""
|
|
35
|
-
if hasattr(object_, attribute_name):
|
|
36
|
-
json_dict[alt_name or attribute_name] = \
|
|
37
|
-
getattr(object_, attribute_name).strftime(DATETIME_STRING_FORMAT)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def add_json_attrib(json_dict: Dict[str, Any], object_,
|
|
41
|
-
attribute_name: str, alt_name: str = None):
|
|
42
|
-
"""Add the results of the to_json() function call of the attribute from the object to the dict.
|
|
43
|
-
|
|
44
|
-
Used to dynamically add the JSON converted value of the attribute if the value is present.
|
|
45
|
-
|
|
46
|
-
Parameters
|
|
47
|
-
----------
|
|
48
|
-
json_dict: The dictionary to add the attribute to
|
|
49
|
-
object_: The object to look for the attribute on
|
|
50
|
-
attribute_name: The name of the attribute to look for
|
|
51
|
-
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
52
|
-
"""
|
|
53
|
-
if hasattr(object_, attribute_name):
|
|
54
|
-
attribute_value = getattr(object_, attribute_name)
|
|
55
|
-
if attribute_value:
|
|
56
|
-
json_dict[alt_name or attribute_name] = attribute_value.to_json()
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
|
|
3
|
+
from ...constants import DATETIME_STRING_FORMAT
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def add_attrib(json_dict: Dict[str, Any], object_,
|
|
7
|
+
attribute_name: str, alt_name: str = None):
|
|
8
|
+
"""Add the value of the attribute from the object to the dictionary.
|
|
9
|
+
|
|
10
|
+
Used to dynamically add the value of the attribute if the value is present.
|
|
11
|
+
|
|
12
|
+
Parameters
|
|
13
|
+
----------
|
|
14
|
+
json_dict: The dictionary to add the attribute to
|
|
15
|
+
object_: The object to look for the attribute on
|
|
16
|
+
attribute_name: The name of the attribute to look for
|
|
17
|
+
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
18
|
+
"""
|
|
19
|
+
if hasattr(object_, attribute_name):
|
|
20
|
+
json_dict[alt_name or attribute_name] = \
|
|
21
|
+
getattr(object_, attribute_name)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def add_datetime_attrib(json_dict: Dict[str, Any], object_,
|
|
25
|
+
attribute_name: str, alt_name: str = None):
|
|
26
|
+
"""Add the value of the attribute from the object to the dictionary converted into a string.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
json_dict: The dictionary to add the attribute to
|
|
31
|
+
object_: The object to look for the attribute on
|
|
32
|
+
attribute_name: The name of the attribute to look for
|
|
33
|
+
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
34
|
+
"""
|
|
35
|
+
if hasattr(object_, attribute_name):
|
|
36
|
+
json_dict[alt_name or attribute_name] = \
|
|
37
|
+
getattr(object_, attribute_name).strftime(DATETIME_STRING_FORMAT)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def add_json_attrib(json_dict: Dict[str, Any], object_,
|
|
41
|
+
attribute_name: str, alt_name: str = None):
|
|
42
|
+
"""Add the results of the to_json() function call of the attribute from the object to the dict.
|
|
43
|
+
|
|
44
|
+
Used to dynamically add the JSON converted value of the attribute if the value is present.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
json_dict: The dictionary to add the attribute to
|
|
49
|
+
object_: The object to look for the attribute on
|
|
50
|
+
attribute_name: The name of the attribute to look for
|
|
51
|
+
alt_name: An alternate name to provide to the attribute in the in the dictionary
|
|
52
|
+
"""
|
|
53
|
+
if hasattr(object_, attribute_name):
|
|
54
|
+
attribute_value = getattr(object_, attribute_name)
|
|
55
|
+
if attribute_value:
|
|
56
|
+
json_dict[alt_name or attribute_name] = attribute_value.to_json()
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
"""Durable Orchestrator.
|
|
2
|
-
|
|
3
|
-
Responsible for orchestrating the execution of the user defined generator
|
|
4
|
-
function.
|
|
5
|
-
"""
|
|
6
|
-
from azure.durable_functions.models.TaskOrchestrationExecutor import TaskOrchestrationExecutor
|
|
7
|
-
from typing import Callable, Any, Generator
|
|
8
|
-
|
|
9
|
-
from .models import DurableOrchestrationContext
|
|
10
|
-
|
|
11
|
-
import azure.functions as func
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Orchestrator:
|
|
15
|
-
"""Durable Orchestration Class.
|
|
16
|
-
|
|
17
|
-
Responsible for orchestrating the execution of the user defined generator
|
|
18
|
-
function.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
def __init__(self,
|
|
22
|
-
activity_func: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]]):
|
|
23
|
-
"""Create a new orchestrator for the user defined generator.
|
|
24
|
-
|
|
25
|
-
Responsible for orchestrating the execution of the user defined
|
|
26
|
-
generator function.
|
|
27
|
-
:param activity_func: Generator function to orchestrate.
|
|
28
|
-
"""
|
|
29
|
-
self.fn: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]] = activity_func
|
|
30
|
-
self.task_orchestration_executor = TaskOrchestrationExecutor()
|
|
31
|
-
|
|
32
|
-
def handle(self, context: DurableOrchestrationContext) -> str:
|
|
33
|
-
"""Handle the orchestration of the user defined generator function.
|
|
34
|
-
|
|
35
|
-
Parameters
|
|
36
|
-
----------
|
|
37
|
-
context : DurableOrchestrationContext
|
|
38
|
-
The DF orchestration context
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
str
|
|
43
|
-
The JSON-formatted string representing the user's orchestration
|
|
44
|
-
state after this invocation
|
|
45
|
-
"""
|
|
46
|
-
self.durable_context = context
|
|
47
|
-
return self.task_orchestration_executor.execute(context, context.histories, self.fn)
|
|
48
|
-
|
|
49
|
-
@classmethod
|
|
50
|
-
def create(cls, fn: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]]) \
|
|
51
|
-
-> Callable[[Any], str]:
|
|
52
|
-
"""Create an instance of the orchestration class.
|
|
53
|
-
|
|
54
|
-
Parameters
|
|
55
|
-
----------
|
|
56
|
-
fn: Callable[[DurableOrchestrationContext], Iterator[Any]]
|
|
57
|
-
Generator function that needs orchestration
|
|
58
|
-
|
|
59
|
-
Returns
|
|
60
|
-
-------
|
|
61
|
-
Callable[[Any], str]
|
|
62
|
-
Handle function of the newly created orchestration client
|
|
63
|
-
"""
|
|
64
|
-
|
|
65
|
-
def handle(context: func.OrchestrationContext) -> str:
|
|
66
|
-
context_body = getattr(context, "body", None)
|
|
67
|
-
if context_body is None:
|
|
68
|
-
context_body = context
|
|
69
|
-
return Orchestrator(fn).handle(DurableOrchestrationContext.from_json(context_body))
|
|
70
|
-
|
|
71
|
-
return handle
|
|
1
|
+
"""Durable Orchestrator.
|
|
2
|
+
|
|
3
|
+
Responsible for orchestrating the execution of the user defined generator
|
|
4
|
+
function.
|
|
5
|
+
"""
|
|
6
|
+
from azure.durable_functions.models.TaskOrchestrationExecutor import TaskOrchestrationExecutor
|
|
7
|
+
from typing import Callable, Any, Generator
|
|
8
|
+
|
|
9
|
+
from .models import DurableOrchestrationContext
|
|
10
|
+
|
|
11
|
+
import azure.functions as func
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Orchestrator:
|
|
15
|
+
"""Durable Orchestration Class.
|
|
16
|
+
|
|
17
|
+
Responsible for orchestrating the execution of the user defined generator
|
|
18
|
+
function.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self,
|
|
22
|
+
activity_func: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]]):
|
|
23
|
+
"""Create a new orchestrator for the user defined generator.
|
|
24
|
+
|
|
25
|
+
Responsible for orchestrating the execution of the user defined
|
|
26
|
+
generator function.
|
|
27
|
+
:param activity_func: Generator function to orchestrate.
|
|
28
|
+
"""
|
|
29
|
+
self.fn: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]] = activity_func
|
|
30
|
+
self.task_orchestration_executor = TaskOrchestrationExecutor()
|
|
31
|
+
|
|
32
|
+
def handle(self, context: DurableOrchestrationContext) -> str:
|
|
33
|
+
"""Handle the orchestration of the user defined generator function.
|
|
34
|
+
|
|
35
|
+
Parameters
|
|
36
|
+
----------
|
|
37
|
+
context : DurableOrchestrationContext
|
|
38
|
+
The DF orchestration context
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
str
|
|
43
|
+
The JSON-formatted string representing the user's orchestration
|
|
44
|
+
state after this invocation
|
|
45
|
+
"""
|
|
46
|
+
self.durable_context = context
|
|
47
|
+
return self.task_orchestration_executor.execute(context, context.histories, self.fn)
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def create(cls, fn: Callable[[DurableOrchestrationContext], Generator[Any, Any, Any]]) \
|
|
51
|
+
-> Callable[[Any], str]:
|
|
52
|
+
"""Create an instance of the orchestration class.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
fn: Callable[[DurableOrchestrationContext], Iterator[Any]]
|
|
57
|
+
Generator function that needs orchestration
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
Callable[[Any], str]
|
|
62
|
+
Handle function of the newly created orchestration client
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
def handle(context: func.OrchestrationContext) -> str:
|
|
66
|
+
context_body = getattr(context, "body", None)
|
|
67
|
+
if context_body is None:
|
|
68
|
+
context_body = context
|
|
69
|
+
return Orchestrator(fn).handle(DurableOrchestrationContext.from_json(context_body))
|
|
70
|
+
|
|
71
|
+
return handle
|
{azure_functions_durable-1.2.8.dist-info → azure_functions_durable-1.2.10.dist-info}/LICENSE
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Katy Shimizu
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Katy Shimizu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|