durabletask 0.4.1__py3-none-any.whl → 0.5.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.
Potentially problematic release.
This version of durabletask might be problematic. Click here for more details.
- durabletask/client.py +15 -1
- durabletask/entities/__init__.py +13 -0
- durabletask/entities/durable_entity.py +93 -0
- durabletask/entities/entity_context.py +154 -0
- durabletask/entities/entity_instance_id.py +40 -0
- durabletask/entities/entity_lock.py +17 -0
- durabletask/internal/entity_state_shim.py +66 -0
- durabletask/internal/helpers.py +58 -0
- durabletask/internal/orchestration_entity_context.py +115 -0
- durabletask/task.py +69 -0
- durabletask/worker.py +473 -11
- {durabletask-0.4.1.dist-info → durabletask-0.5.0.dist-info}/METADATA +1 -1
- durabletask-0.5.0.dist-info/RECORD +23 -0
- durabletask-0.4.1.dist-info/RECORD +0 -16
- {durabletask-0.4.1.dist-info → durabletask-0.5.0.dist-info}/WHEEL +0 -0
- {durabletask-0.4.1.dist-info → durabletask-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {durabletask-0.4.1.dist-info → durabletask-0.5.0.dist-info}/top_level.txt +0 -0
durabletask/task.py
CHANGED
|
@@ -9,6 +9,7 @@ from abc import ABC, abstractmethod
|
|
|
9
9
|
from datetime import datetime, timedelta
|
|
10
10
|
from typing import Any, Callable, Generator, Generic, Optional, TypeVar, Union
|
|
11
11
|
|
|
12
|
+
from durabletask.entities import DurableEntity, EntityInstanceId, EntityLock, EntityContext
|
|
12
13
|
import durabletask.internal.helpers as pbh
|
|
13
14
|
import durabletask.internal.orchestrator_service_pb2 as pb
|
|
14
15
|
|
|
@@ -137,6 +138,68 @@ class OrchestrationContext(ABC):
|
|
|
137
138
|
"""
|
|
138
139
|
pass
|
|
139
140
|
|
|
141
|
+
@abstractmethod
|
|
142
|
+
def call_entity(self, entity: EntityInstanceId,
|
|
143
|
+
operation: str,
|
|
144
|
+
input: Optional[TInput] = None) -> Task:
|
|
145
|
+
"""Schedule entity function for execution.
|
|
146
|
+
|
|
147
|
+
Parameters
|
|
148
|
+
----------
|
|
149
|
+
entity: EntityInstanceId
|
|
150
|
+
The ID of the entity instance to call.
|
|
151
|
+
operation: str
|
|
152
|
+
The name of the operation to invoke on the entity.
|
|
153
|
+
input: Optional[TInput]
|
|
154
|
+
The optional JSON-serializable input to pass to the entity function.
|
|
155
|
+
|
|
156
|
+
Returns
|
|
157
|
+
-------
|
|
158
|
+
Task
|
|
159
|
+
A Durable Task that completes when the called entity function completes or fails.
|
|
160
|
+
"""
|
|
161
|
+
pass
|
|
162
|
+
|
|
163
|
+
@abstractmethod
|
|
164
|
+
def signal_entity(
|
|
165
|
+
self,
|
|
166
|
+
entity_id: EntityInstanceId,
|
|
167
|
+
operation_name: str,
|
|
168
|
+
input: Optional[TInput] = None
|
|
169
|
+
) -> None:
|
|
170
|
+
"""Signal an entity function for execution.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
entity_id: EntityInstanceId
|
|
175
|
+
The ID of the entity instance to signal.
|
|
176
|
+
operation_name: str
|
|
177
|
+
The name of the operation to invoke on the entity.
|
|
178
|
+
input: Optional[TInput]
|
|
179
|
+
The optional JSON-serializable input to pass to the entity function.
|
|
180
|
+
"""
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
@abstractmethod
|
|
184
|
+
def lock_entities(self, entities: list[EntityInstanceId]) -> Task[EntityLock]:
|
|
185
|
+
"""Creates a Task object that locks the specified entity instances.
|
|
186
|
+
|
|
187
|
+
The locks will be acquired the next time the orchestrator yields.
|
|
188
|
+
Best practice is to immediately yield this Task and enter the returned EntityLock.
|
|
189
|
+
The lock is released when the EntityLock is exited.
|
|
190
|
+
|
|
191
|
+
Parameters
|
|
192
|
+
----------
|
|
193
|
+
entities: list[EntityInstanceId]
|
|
194
|
+
The list of entity instance IDs to lock.
|
|
195
|
+
|
|
196
|
+
Returns
|
|
197
|
+
-------
|
|
198
|
+
EntityLock
|
|
199
|
+
A context manager object that releases the locks when exited.
|
|
200
|
+
"""
|
|
201
|
+
pass
|
|
202
|
+
|
|
140
203
|
@abstractmethod
|
|
141
204
|
def call_sub_orchestrator(self, orchestrator: Orchestrator[TInput, TOutput], *,
|
|
142
205
|
input: Optional[TInput] = None,
|
|
@@ -195,6 +258,10 @@ class OrchestrationContext(ABC):
|
|
|
195
258
|
"""
|
|
196
259
|
pass
|
|
197
260
|
|
|
261
|
+
@abstractmethod
|
|
262
|
+
def _exit_critical_section(self) -> None:
|
|
263
|
+
pass
|
|
264
|
+
|
|
198
265
|
|
|
199
266
|
class FailureDetails:
|
|
200
267
|
def __init__(self, message: str, error_type: str, stack_trace: Optional[str]):
|
|
@@ -458,6 +525,8 @@ Orchestrator = Callable[[OrchestrationContext, TInput], Union[Generator[Task, An
|
|
|
458
525
|
# Activities are simple functions that can be scheduled by orchestrators
|
|
459
526
|
Activity = Callable[[ActivityContext, TInput], TOutput]
|
|
460
527
|
|
|
528
|
+
Entity = Union[Callable[[EntityContext, TInput], TOutput], type[DurableEntity]]
|
|
529
|
+
|
|
461
530
|
|
|
462
531
|
class RetryPolicy:
|
|
463
532
|
"""Represents the retry policy for an orchestration or activity function."""
|