azure-functions-durable 1.2.9__py3-none-any.whl → 1.3.0__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 +260 -249
- azure/durable_functions/decorators/metadata.py +109 -109
- azure/durable_functions/entity.py +129 -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 +812 -781
- azure/durable_functions/models/DurableOrchestrationContext.py +761 -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 -32
- azure/durable_functions/models/OrchestratorState.py +117 -116
- azure/durable_functions/models/PurgeHistoryResult.py +33 -33
- azure/durable_functions/models/ReplaySchema.py +9 -8
- azure/durable_functions/models/RetryOptions.py +69 -69
- azure/durable_functions/models/RpcManagementOptions.py +86 -86
- azure/durable_functions/models/Task.py +540 -426
- azure/durable_functions/models/TaskOrchestrationExecutor.py +352 -336
- azure/durable_functions/models/TokenSource.py +56 -56
- azure/durable_functions/models/__init__.py +26 -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 +94 -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 -27
- 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 +80 -69
- azure/durable_functions/models/utils/json_utils.py +96 -56
- azure/durable_functions/orchestrator.py +73 -71
- azure/durable_functions/testing/OrchestratorGeneratorWrapper.py +42 -0
- azure/durable_functions/testing/__init__.py +6 -0
- {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/LICENSE +21 -21
- {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/METADATA +59 -58
- azure_functions_durable-1.3.0.dist-info/RECORD +103 -0
- {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.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 -68
- tests/models/test_DurableOrchestrationClient.py +730 -730
- 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 +397 -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 -841
- 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_long_timers.py +70 -0
- 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.9.data/data/_manifest/bsi.json +0 -1
- azure_functions_durable-1.2.9.data/data/_manifest/manifest.cat +0 -0
- azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json +0 -11985
- azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
- azure_functions_durable-1.2.9.dist-info/RECORD +0 -102
- {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional, Union
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from .ActionType import ActionType
|
|
5
|
-
from ..utils.json_utils import add_attrib
|
|
6
|
-
from json import dumps
|
|
7
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class CallSubOrchestratorAction(Action):
|
|
11
|
-
"""Defines the structure of the Call SubOrchestrator object."""
|
|
12
|
-
|
|
13
|
-
def __init__(self, function_name: str, _input: Optional[Any] = None,
|
|
14
|
-
instance_id: Optional[str] = None):
|
|
15
|
-
self.function_name: str = function_name
|
|
16
|
-
self._input: str = dumps(_input, default=_serialize_custom_object)
|
|
17
|
-
self.instance_id: Optional[str] = instance_id
|
|
18
|
-
|
|
19
|
-
if not self.function_name:
|
|
20
|
-
raise ValueError("function_name cannot be empty")
|
|
21
|
-
|
|
22
|
-
@property
|
|
23
|
-
def action_type(self) -> int:
|
|
24
|
-
"""Get the type of action this class represents."""
|
|
25
|
-
return ActionType.CALL_SUB_ORCHESTRATOR
|
|
26
|
-
|
|
27
|
-
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
28
|
-
"""Convert object into a json dictionary.
|
|
29
|
-
|
|
30
|
-
Returns
|
|
31
|
-
-------
|
|
32
|
-
Dict[str, Union(str, int)]
|
|
33
|
-
The instance of the class converted into a json dictionary
|
|
34
|
-
"""
|
|
35
|
-
json_dict: Dict[str, Union[str, int]] = {}
|
|
36
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
37
|
-
add_attrib(json_dict, self, 'function_name', 'functionName')
|
|
38
|
-
add_attrib(json_dict, self, '_input', 'input')
|
|
39
|
-
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
40
|
-
return json_dict
|
|
1
|
+
from typing import Any, Dict, Optional, Union
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from .ActionType import ActionType
|
|
5
|
+
from ..utils.json_utils import add_attrib
|
|
6
|
+
from json import dumps
|
|
7
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CallSubOrchestratorAction(Action):
|
|
11
|
+
"""Defines the structure of the Call SubOrchestrator object."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, function_name: str, _input: Optional[Any] = None,
|
|
14
|
+
instance_id: Optional[str] = None):
|
|
15
|
+
self.function_name: str = function_name
|
|
16
|
+
self._input: str = dumps(_input, default=_serialize_custom_object)
|
|
17
|
+
self.instance_id: Optional[str] = instance_id
|
|
18
|
+
|
|
19
|
+
if not self.function_name:
|
|
20
|
+
raise ValueError("function_name cannot be empty")
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def action_type(self) -> int:
|
|
24
|
+
"""Get the type of action this class represents."""
|
|
25
|
+
return ActionType.CALL_SUB_ORCHESTRATOR
|
|
26
|
+
|
|
27
|
+
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
28
|
+
"""Convert object into a json dictionary.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
Dict[str, Union(str, int)]
|
|
33
|
+
The instance of the class converted into a json dictionary
|
|
34
|
+
"""
|
|
35
|
+
json_dict: Dict[str, Union[str, int]] = {}
|
|
36
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
37
|
+
add_attrib(json_dict, self, 'function_name', 'functionName')
|
|
38
|
+
add_attrib(json_dict, self, '_input', 'input')
|
|
39
|
+
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
40
|
+
return json_dict
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
from typing import Any, Dict, Union, Optional
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from .ActionType import ActionType
|
|
5
|
-
from ..utils.json_utils import add_attrib, add_json_attrib
|
|
6
|
-
from json import dumps
|
|
7
|
-
from ..RetryOptions import RetryOptions
|
|
8
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class CallSubOrchestratorWithRetryAction(Action):
|
|
12
|
-
"""Defines the structure of the Call SubOrchestrator object."""
|
|
13
|
-
|
|
14
|
-
def __init__(self, function_name: str, retry_options: RetryOptions,
|
|
15
|
-
_input: Optional[Any] = None,
|
|
16
|
-
instance_id: Optional[str] = None):
|
|
17
|
-
self.function_name: str = function_name
|
|
18
|
-
self._input: str = dumps(_input, default=_serialize_custom_object)
|
|
19
|
-
self.retry_options: RetryOptions = retry_options
|
|
20
|
-
self.instance_id: Optional[str] = instance_id
|
|
21
|
-
|
|
22
|
-
if not self.function_name:
|
|
23
|
-
raise ValueError("function_name cannot be empty")
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def action_type(self) -> int:
|
|
27
|
-
"""Get the type of action this class represents."""
|
|
28
|
-
return ActionType.CALL_SUB_ORCHESTRATOR_WITH_RETRY
|
|
29
|
-
|
|
30
|
-
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
31
|
-
"""Convert object into a json dictionary.
|
|
32
|
-
|
|
33
|
-
Returns
|
|
34
|
-
-------
|
|
35
|
-
Dict[str, Union(str, int)]
|
|
36
|
-
The instance of the class converted into a json dictionary
|
|
37
|
-
"""
|
|
38
|
-
json_dict: Dict[str, Union[str, int]] = {}
|
|
39
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
40
|
-
add_attrib(json_dict, self, 'function_name', 'functionName')
|
|
41
|
-
add_attrib(json_dict, self, '_input', 'input')
|
|
42
|
-
add_json_attrib(json_dict, self, 'retry_options', 'retryOptions')
|
|
43
|
-
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
44
|
-
return json_dict
|
|
1
|
+
from typing import Any, Dict, Union, Optional
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from .ActionType import ActionType
|
|
5
|
+
from ..utils.json_utils import add_attrib, add_json_attrib
|
|
6
|
+
from json import dumps
|
|
7
|
+
from ..RetryOptions import RetryOptions
|
|
8
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CallSubOrchestratorWithRetryAction(Action):
|
|
12
|
+
"""Defines the structure of the Call SubOrchestrator object."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, function_name: str, retry_options: RetryOptions,
|
|
15
|
+
_input: Optional[Any] = None,
|
|
16
|
+
instance_id: Optional[str] = None):
|
|
17
|
+
self.function_name: str = function_name
|
|
18
|
+
self._input: str = dumps(_input, default=_serialize_custom_object)
|
|
19
|
+
self.retry_options: RetryOptions = retry_options
|
|
20
|
+
self.instance_id: Optional[str] = instance_id
|
|
21
|
+
|
|
22
|
+
if not self.function_name:
|
|
23
|
+
raise ValueError("function_name cannot be empty")
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def action_type(self) -> int:
|
|
27
|
+
"""Get the type of action this class represents."""
|
|
28
|
+
return ActionType.CALL_SUB_ORCHESTRATOR_WITH_RETRY
|
|
29
|
+
|
|
30
|
+
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
31
|
+
"""Convert object into a json dictionary.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
Dict[str, Union(str, int)]
|
|
36
|
+
The instance of the class converted into a json dictionary
|
|
37
|
+
"""
|
|
38
|
+
json_dict: Dict[str, Union[str, int]] = {}
|
|
39
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
40
|
+
add_attrib(json_dict, self, 'function_name', 'functionName')
|
|
41
|
+
add_attrib(json_dict, self, '_input', 'input')
|
|
42
|
+
add_json_attrib(json_dict, self, 'retry_options', 'retryOptions')
|
|
43
|
+
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
44
|
+
return json_dict
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
from typing import Dict, Union
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from ..utils.json_utils import add_attrib
|
|
5
|
-
from typing import List
|
|
6
|
-
from abc import abstractmethod
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class CompoundAction(Action):
|
|
10
|
-
"""Defines the structure of the WhenAll Action object.
|
|
11
|
-
|
|
12
|
-
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def __init__(self, compound_tasks: List[Action]):
|
|
16
|
-
self.compound_tasks = compound_tasks
|
|
17
|
-
|
|
18
|
-
@property
|
|
19
|
-
@abstractmethod
|
|
20
|
-
def action_type(self) -> int:
|
|
21
|
-
"""Get this object's action type as an integer."""
|
|
22
|
-
...
|
|
23
|
-
|
|
24
|
-
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
25
|
-
"""Convert object into a json dictionary.
|
|
26
|
-
|
|
27
|
-
Returns
|
|
28
|
-
-------
|
|
29
|
-
Dict[str, Union[str, int]]
|
|
30
|
-
The instance of the class converted into a json dictionary
|
|
31
|
-
"""
|
|
32
|
-
json_dict: Dict[str, Union[str, int]] = {}
|
|
33
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
34
|
-
json_dict['compoundActions'] = list(map(lambda x: x.to_json(), self.compound_tasks))
|
|
35
|
-
return json_dict
|
|
1
|
+
from typing import Dict, Union
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from ..utils.json_utils import add_attrib
|
|
5
|
+
from typing import List
|
|
6
|
+
from abc import abstractmethod
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CompoundAction(Action):
|
|
10
|
+
"""Defines the structure of the WhenAll Action object.
|
|
11
|
+
|
|
12
|
+
Provides the information needed by the durable extension to be able to invoke WhenAll tasks.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, compound_tasks: List[Action]):
|
|
16
|
+
self.compound_tasks = compound_tasks
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def action_type(self) -> int:
|
|
21
|
+
"""Get this object's action type as an integer."""
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
def to_json(self) -> Dict[str, Union[str, int]]:
|
|
25
|
+
"""Convert object into a json dictionary.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
Dict[str, Union[str, int]]
|
|
30
|
+
The instance of the class converted into a json dictionary
|
|
31
|
+
"""
|
|
32
|
+
json_dict: Dict[str, Union[str, int]] = {}
|
|
33
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
34
|
+
json_dict['compoundActions'] = list(map(lambda x: x.to_json(), self.compound_tasks))
|
|
35
|
+
return json_dict
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
from typing import Dict, Union
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from .ActionType import ActionType
|
|
5
|
-
from ..utils.json_utils import add_attrib
|
|
6
|
-
from json import dumps
|
|
7
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ContinueAsNewAction(Action):
|
|
11
|
-
"""Defines the structure of the Continue As New object.
|
|
12
|
-
|
|
13
|
-
Provides the information needed by the durable extension to be able to reset the orchestration
|
|
14
|
-
and continue as new.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, input_=None):
|
|
18
|
-
self.input_ = dumps(input_, default=_serialize_custom_object)
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def action_type(self) -> int:
|
|
22
|
-
"""Get the type of action this class represents."""
|
|
23
|
-
return ActionType.CONTINUE_AS_NEW
|
|
24
|
-
|
|
25
|
-
def to_json(self) -> Dict[str, Union[int, str]]:
|
|
26
|
-
"""Convert object into a json dictionary.
|
|
27
|
-
|
|
28
|
-
Returns
|
|
29
|
-
-------
|
|
30
|
-
Dict[str, Any]
|
|
31
|
-
The instance of the class converted into a json dictionary
|
|
32
|
-
"""
|
|
33
|
-
json_dict: Dict[str, Union[int, str]] = {}
|
|
34
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
35
|
-
add_attrib(json_dict, self, 'input_', 'input')
|
|
36
|
-
return json_dict
|
|
1
|
+
from typing import Dict, Union
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from .ActionType import ActionType
|
|
5
|
+
from ..utils.json_utils import add_attrib
|
|
6
|
+
from json import dumps
|
|
7
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ContinueAsNewAction(Action):
|
|
11
|
+
"""Defines the structure of the Continue As New object.
|
|
12
|
+
|
|
13
|
+
Provides the information needed by the durable extension to be able to reset the orchestration
|
|
14
|
+
and continue as new.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, input_=None):
|
|
18
|
+
self.input_ = dumps(input_, default=_serialize_custom_object)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def action_type(self) -> int:
|
|
22
|
+
"""Get the type of action this class represents."""
|
|
23
|
+
return ActionType.CONTINUE_AS_NEW
|
|
24
|
+
|
|
25
|
+
def to_json(self) -> Dict[str, Union[int, str]]:
|
|
26
|
+
"""Convert object into a json dictionary.
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
Dict[str, Any]
|
|
31
|
+
The instance of the class converted into a json dictionary
|
|
32
|
+
"""
|
|
33
|
+
json_dict: Dict[str, Union[int, str]] = {}
|
|
34
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
35
|
+
add_attrib(json_dict, self, 'input_', 'input')
|
|
36
|
+
return json_dict
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
from typing import Any, Dict, Union
|
|
2
|
-
|
|
3
|
-
from .ActionType import ActionType
|
|
4
|
-
from .Action import Action
|
|
5
|
-
from ..utils.json_utils import add_attrib, add_datetime_attrib
|
|
6
|
-
import datetime
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class CreateTimerAction(Action):
|
|
10
|
-
"""Defines the structure of the Create Timer object.
|
|
11
|
-
|
|
12
|
-
Returns
|
|
13
|
-
-------
|
|
14
|
-
Information needed by durable extension to schedule the activity
|
|
15
|
-
|
|
16
|
-
Raises
|
|
17
|
-
------
|
|
18
|
-
ValueError
|
|
19
|
-
if the event fired is not of valid datetime object
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(self, fire_at: datetime.datetime, is_cancelled: bool = False):
|
|
23
|
-
self._action_type: ActionType = ActionType.CREATE_TIMER
|
|
24
|
-
self.fire_at: datetime.datetime = fire_at
|
|
25
|
-
self.is_cancelled: bool = is_cancelled
|
|
26
|
-
|
|
27
|
-
if not isinstance(self.fire_at, datetime.date):
|
|
28
|
-
raise ValueError("fireAt: Expected valid datetime object but got ", self.fire_at)
|
|
29
|
-
|
|
30
|
-
def to_json(self) -> Dict[str, Any]:
|
|
31
|
-
"""
|
|
32
|
-
Convert object into a json dictionary.
|
|
33
|
-
|
|
34
|
-
Returns
|
|
35
|
-
-------
|
|
36
|
-
Dict[str, Any]
|
|
37
|
-
The instance of the class converted into a json dictionary
|
|
38
|
-
"""
|
|
39
|
-
json_dict: Dict[str, Union[int, str]] = {}
|
|
40
|
-
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
41
|
-
add_datetime_attrib(json_dict, self, 'fire_at', 'fireAt')
|
|
42
|
-
add_attrib(json_dict, self, 'is_cancelled', 'isCanceled')
|
|
43
|
-
return json_dict
|
|
44
|
-
|
|
45
|
-
@property
|
|
46
|
-
def action_type(self) -> int:
|
|
47
|
-
"""Get the type of action this class represents."""
|
|
48
|
-
return ActionType.CREATE_TIMER
|
|
1
|
+
from typing import Any, Dict, Union
|
|
2
|
+
|
|
3
|
+
from .ActionType import ActionType
|
|
4
|
+
from .Action import Action
|
|
5
|
+
from ..utils.json_utils import add_attrib, add_datetime_attrib
|
|
6
|
+
import datetime
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CreateTimerAction(Action):
|
|
10
|
+
"""Defines the structure of the Create Timer object.
|
|
11
|
+
|
|
12
|
+
Returns
|
|
13
|
+
-------
|
|
14
|
+
Information needed by durable extension to schedule the activity
|
|
15
|
+
|
|
16
|
+
Raises
|
|
17
|
+
------
|
|
18
|
+
ValueError
|
|
19
|
+
if the event fired is not of valid datetime object
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, fire_at: datetime.datetime, is_cancelled: bool = False):
|
|
23
|
+
self._action_type: ActionType = ActionType.CREATE_TIMER
|
|
24
|
+
self.fire_at: datetime.datetime = fire_at
|
|
25
|
+
self.is_cancelled: bool = is_cancelled
|
|
26
|
+
|
|
27
|
+
if not isinstance(self.fire_at, datetime.date):
|
|
28
|
+
raise ValueError("fireAt: Expected valid datetime object but got ", self.fire_at)
|
|
29
|
+
|
|
30
|
+
def to_json(self) -> Dict[str, Any]:
|
|
31
|
+
"""
|
|
32
|
+
Convert object into a json dictionary.
|
|
33
|
+
|
|
34
|
+
Returns
|
|
35
|
+
-------
|
|
36
|
+
Dict[str, Any]
|
|
37
|
+
The instance of the class converted into a json dictionary
|
|
38
|
+
"""
|
|
39
|
+
json_dict: Dict[str, Union[int, str]] = {}
|
|
40
|
+
add_attrib(json_dict, self, 'action_type', 'actionType')
|
|
41
|
+
add_datetime_attrib(json_dict, self, 'fire_at', 'fireAt')
|
|
42
|
+
add_attrib(json_dict, self, 'is_cancelled', 'isCanceled')
|
|
43
|
+
return json_dict
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def action_type(self) -> int:
|
|
47
|
+
"""Get the type of action this class represents."""
|
|
48
|
+
return ActionType.CREATE_TIMER
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
from azure.durable_functions.models.actions.Action import Action
|
|
2
|
-
from typing import Any, Dict, Optional
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class NoOpAction(Action):
|
|
6
|
-
"""A no-op action, for anonymous tasks only."""
|
|
7
|
-
|
|
8
|
-
def __init__(self, metadata: Optional[str] = None):
|
|
9
|
-
"""Create a NoOpAction object.
|
|
10
|
-
|
|
11
|
-
This is an internal-only action class used to represent cases when intermediate
|
|
12
|
-
tasks are used to implement some API. For example, in -WithRetry APIs, intermediate
|
|
13
|
-
timers are created. We create this NoOp action to track those the backing actions
|
|
14
|
-
of those tasks, which is necessary because we mimic the DF-internal replay algorithm.
|
|
15
|
-
|
|
16
|
-
Parameters
|
|
17
|
-
----------
|
|
18
|
-
metadata : Optional[str]
|
|
19
|
-
Used for internal debugging: metadata about the action being represented.
|
|
20
|
-
"""
|
|
21
|
-
self.metadata = metadata
|
|
22
|
-
|
|
23
|
-
def action_type(self) -> int:
|
|
24
|
-
"""Get the type of action this class represents."""
|
|
25
|
-
raise Exception("Attempted to get action type of an anonymous Action")
|
|
26
|
-
|
|
27
|
-
def to_json(self) -> Dict[str, Any]:
|
|
28
|
-
"""Convert object into a json dictionary.
|
|
29
|
-
|
|
30
|
-
Returns
|
|
31
|
-
-------
|
|
32
|
-
Dict[str, Any]
|
|
33
|
-
The instance of the class converted into a json dictionary
|
|
34
|
-
"""
|
|
35
|
-
raise Exception("Attempted to convert an anonymous Action to JSON")
|
|
1
|
+
from azure.durable_functions.models.actions.Action import Action
|
|
2
|
+
from typing import Any, Dict, Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class NoOpAction(Action):
|
|
6
|
+
"""A no-op action, for anonymous tasks only."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, metadata: Optional[str] = None):
|
|
9
|
+
"""Create a NoOpAction object.
|
|
10
|
+
|
|
11
|
+
This is an internal-only action class used to represent cases when intermediate
|
|
12
|
+
tasks are used to implement some API. For example, in -WithRetry APIs, intermediate
|
|
13
|
+
timers are created. We create this NoOp action to track those the backing actions
|
|
14
|
+
of those tasks, which is necessary because we mimic the DF-internal replay algorithm.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
metadata : Optional[str]
|
|
19
|
+
Used for internal debugging: metadata about the action being represented.
|
|
20
|
+
"""
|
|
21
|
+
self.metadata = metadata
|
|
22
|
+
|
|
23
|
+
def action_type(self) -> int:
|
|
24
|
+
"""Get the type of action this class represents."""
|
|
25
|
+
raise Exception("Attempted to get action type of an anonymous Action")
|
|
26
|
+
|
|
27
|
+
def to_json(self) -> Dict[str, Any]:
|
|
28
|
+
"""Convert object into a json dictionary.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
Dict[str, Any]
|
|
33
|
+
The instance of the class converted into a json dictionary
|
|
34
|
+
"""
|
|
35
|
+
raise Exception("Attempted to convert an anonymous Action to JSON")
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
from typing import Any, Dict
|
|
2
|
-
|
|
3
|
-
from .Action import Action
|
|
4
|
-
from .ActionType import ActionType
|
|
5
|
-
from ..utils.json_utils import add_attrib
|
|
6
|
-
from json import dumps
|
|
7
|
-
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
-
from ..utils.entity_utils import EntityId
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class SignalEntityAction(Action):
|
|
12
|
-
"""Defines the structure of the Signal Entity object.
|
|
13
|
-
|
|
14
|
-
Provides the information needed by the durable extension to be able to signal an entity
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, entity_id: EntityId, operation: str, input_=None):
|
|
18
|
-
self.entity_id: EntityId = entity_id
|
|
19
|
-
|
|
20
|
-
# Validating that EntityId exists before trying to parse its instanceId
|
|
21
|
-
if not self.entity_id:
|
|
22
|
-
raise ValueError("entity_id cannot be empty")
|
|
23
|
-
|
|
24
|
-
self.instance_id: str = EntityId.get_scheduler_id(entity_id)
|
|
25
|
-
self.operation: str = operation
|
|
26
|
-
self.input_: str = dumps(input_, default=_serialize_custom_object)
|
|
27
|
-
|
|
28
|
-
@property
|
|
29
|
-
def action_type(self) -> int:
|
|
30
|
-
"""Get the type of action this class represents."""
|
|
31
|
-
return ActionType.SIGNAL_ENTITY
|
|
32
|
-
|
|
33
|
-
def to_json(self) -> Dict[str, Any]:
|
|
34
|
-
"""Convert object into a json dictionary.
|
|
35
|
-
|
|
36
|
-
Returns
|
|
37
|
-
-------
|
|
38
|
-
Dict[str, Any]
|
|
39
|
-
The instance of the class converted into a json dictionary
|
|
40
|
-
"""
|
|
41
|
-
json_dict: Dict[str, Any] = {}
|
|
42
|
-
add_attrib(json_dict, self, "action_type", "actionType")
|
|
43
|
-
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
44
|
-
add_attrib(json_dict, self, 'operation', 'operation')
|
|
45
|
-
add_attrib(json_dict, self, 'input_', 'input')
|
|
46
|
-
|
|
47
|
-
return json_dict
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
from .Action import Action
|
|
4
|
+
from .ActionType import ActionType
|
|
5
|
+
from ..utils.json_utils import add_attrib
|
|
6
|
+
from json import dumps
|
|
7
|
+
from azure.functions._durable_functions import _serialize_custom_object
|
|
8
|
+
from ..utils.entity_utils import EntityId
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SignalEntityAction(Action):
|
|
12
|
+
"""Defines the structure of the Signal Entity object.
|
|
13
|
+
|
|
14
|
+
Provides the information needed by the durable extension to be able to signal an entity
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, entity_id: EntityId, operation: str, input_=None):
|
|
18
|
+
self.entity_id: EntityId = entity_id
|
|
19
|
+
|
|
20
|
+
# Validating that EntityId exists before trying to parse its instanceId
|
|
21
|
+
if not self.entity_id:
|
|
22
|
+
raise ValueError("entity_id cannot be empty")
|
|
23
|
+
|
|
24
|
+
self.instance_id: str = EntityId.get_scheduler_id(entity_id)
|
|
25
|
+
self.operation: str = operation
|
|
26
|
+
self.input_: str = dumps(input_, default=_serialize_custom_object)
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def action_type(self) -> int:
|
|
30
|
+
"""Get the type of action this class represents."""
|
|
31
|
+
return ActionType.SIGNAL_ENTITY
|
|
32
|
+
|
|
33
|
+
def to_json(self) -> Dict[str, Any]:
|
|
34
|
+
"""Convert object into a json dictionary.
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
Dict[str, Any]
|
|
39
|
+
The instance of the class converted into a json dictionary
|
|
40
|
+
"""
|
|
41
|
+
json_dict: Dict[str, Any] = {}
|
|
42
|
+
add_attrib(json_dict, self, "action_type", "actionType")
|
|
43
|
+
add_attrib(json_dict, self, 'instance_id', 'instanceId')
|
|
44
|
+
add_attrib(json_dict, self, 'operation', 'operation')
|
|
45
|
+
add_attrib(json_dict, self, 'input_', 'input')
|
|
46
|
+
|
|
47
|
+
return json_dict
|