azure-functions-durable 1.2.8__py3-none-any.whl → 1.2.9__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.
@@ -709,3 +709,73 @@ class DurableOrchestrationClient:
709
709
  else:
710
710
  ex_msg = "Received unexpected payload from the durable-extension: " + str(response)
711
711
  raise Exception(ex_msg)
712
+
713
+ async def suspend(self, instance_id: str, reason: str) -> None:
714
+ """Suspend the specified orchestration instance.
715
+
716
+ Parameters
717
+ ----------
718
+ instance_id : str
719
+ The ID of the orchestration instance to suspend.
720
+ reason: str
721
+ The reason for suspending the instance.
722
+
723
+ Raises
724
+ ------
725
+ Exception:
726
+ When the suspend call failed with an unexpected status code
727
+
728
+ Returns
729
+ -------
730
+ None
731
+ """
732
+ request_url = f"{self._orchestration_bindings.rpc_base_url}instances/{instance_id}/" \
733
+ f"suspend?reason={quote(reason)}"
734
+ response = await self._post_async_request(request_url, None)
735
+ switch_statement = {
736
+ 202: lambda: None, # instance is suspended
737
+ 410: lambda: None, # instance completed
738
+ 404: lambda: f"No instance with ID '{instance_id}' found.",
739
+ }
740
+
741
+ has_error_message = switch_statement.get(
742
+ response[0],
743
+ lambda: f"The operation failed with an unexpected status code {response[0]}")
744
+ error_message = has_error_message()
745
+ if error_message:
746
+ raise Exception(error_message)
747
+
748
+ async def resume(self, instance_id: str, reason: str) -> None:
749
+ """Resume the specified orchestration instance.
750
+
751
+ Parameters
752
+ ----------
753
+ instance_id : str
754
+ The ID of the orchestration instance to query.
755
+ reason: str
756
+ The reason for resuming the instance.
757
+
758
+ Raises
759
+ ------
760
+ Exception:
761
+ When the resume call failed with an unexpected status code
762
+
763
+ Returns
764
+ -------
765
+ None
766
+ """
767
+ request_url = f"{self._orchestration_bindings.rpc_base_url}instances/{instance_id}/" \
768
+ f"resume?reason={quote(reason)}"
769
+ response = await self._post_async_request(request_url, None)
770
+ switch_statement = {
771
+ 202: lambda: None, # instance is resumed
772
+ 410: lambda: None, # instance completed
773
+ 404: lambda: f"No instance with ID '{instance_id}' found.",
774
+ }
775
+
776
+ has_error_message = switch_statement.get(
777
+ response[0],
778
+ lambda: f"The operation failed with an unexpected status code {response[0]}")
779
+ error_message = has_error_message()
780
+ if error_message:
781
+ raise Exception(error_message)
@@ -27,3 +27,6 @@ class OrchestrationRuntimeStatus(Enum):
27
27
 
28
28
  Pending = 'Pending'
29
29
  """The orchestration instance has been scheduled but has not yet started running."""
30
+
31
+ Suspended = 'Suspended'
32
+ """The orchestration instance has been suspended and may go back to running at a later time."""
@@ -165,11 +165,14 @@ class TaskOrchestrationExecutor:
165
165
 
166
166
  # We provide the ability to deserialize custom objects, because the output of this
167
167
  # will be passed directly to the orchestrator as the output of some activity
168
- if event_type == HistoryEventType.SUB_ORCHESTRATION_INSTANCE_COMPLETED:
168
+ if (event_type == HistoryEventType.SUB_ORCHESTRATION_INSTANCE_COMPLETED
169
+ and directive_result.Result is not None):
169
170
  return json.loads(directive_result.Result, object_hook=_deserialize_custom_object)
170
- if event_type == HistoryEventType.TASK_COMPLETED:
171
+ if (event_type == HistoryEventType.TASK_COMPLETED
172
+ and directive_result.Result is not None):
171
173
  return json.loads(directive_result.Result, object_hook=_deserialize_custom_object)
172
- if event_type == HistoryEventType.EVENT_RAISED:
174
+ if (event_type == HistoryEventType.EVENT_RAISED
175
+ and directive_result.Input is not None):
173
176
  # TODO: Investigate why the payload is in "Input" instead of "Result"
174
177
  response = json.loads(directive_result.Input,
175
178
  object_hook=_deserialize_custom_object)
@@ -23,3 +23,5 @@ class HistoryEventType(IntEnum):
23
23
  CONTINUE_AS_NEW = 16
24
24
  GENERIC_EVENT = 17
25
25
  HISTORY_STATE = 18
26
+ EXECUTION_SUSPENDED = 19
27
+ EXECUTION_RESUMED = 20
@@ -1 +1 @@
1
- {"Source":"InternalBuild","Data":{"System.CollectionId":"d1c51fbc-4477-4a0f-b99f-fc9013009a58","System.DefinitionId":"58","System.TeamProjectId":"e6a70c92-4128-439f-8012-382fe78d6396","System.TeamProject":"Azure Functions","Build.BuildId":"157277","Build.BuildNumber":"20231107.4","Build.DefinitionName":"Azure.azure-functions-durable-python","Build.DefinitionRevision":"2","Build.Repository.Name":"Azure/azure-functions-durable-python","Build.Repository.Provider":"GitHub","Build.Repository.Id":"Azure/azure-functions-durable-python","Build.SourceBranch":"refs/tags/v1.2.8","Build.SourceBranchName":"v1.2.8","Build.SourceVersion":"7d21ac90c898781504af0faafbd8c5a5a98d42bd"},"Feed":null}
1
+ {"Source":"InternalBuild","Data":{"System.CollectionId":"d1c51fbc-4477-4a0f-b99f-fc9013009a58","System.DefinitionId":"58","System.TeamProjectId":"e6a70c92-4128-439f-8012-382fe78d6396","System.TeamProject":"Azure Functions","Build.BuildId":"161393","Build.BuildNumber":"20240214.1","Build.DefinitionName":"Azure.azure-functions-durable-python","Build.DefinitionRevision":"2","Build.Repository.Name":"Azure/azure-functions-durable-python","Build.Repository.Provider":"GitHub","Build.Repository.Id":"Azure/azure-functions-durable-python","Build.SourceBranch":"refs/tags/v1.2.9","Build.SourceBranchName":"v1.2.9","Build.SourceVersion":"34112b1c6a6100bf602eff0ae3f57918fac61935"},"Feed":null}