Skip to content

Commit d606b35

Browse files
Reduce entity context exposure (#71)
Co-authored-by: Bernd Verst <[email protected]>
1 parent 34eaed6 commit d606b35

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

durabletask/worker.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ class _RuntimeOrchestrationContext(task.OrchestrationContext):
819819
_generator: Optional[Generator[task.Task, Any, Any]]
820820
_previous_task: Optional[task.Task]
821821

822-
def __init__(self, instance_id: str, registry: _Registry, entity_context: OrchestrationEntityContext):
822+
def __init__(self, instance_id: str, registry: _Registry):
823823
self._generator = None
824824
self._is_replaying = True
825825
self._is_complete = False
@@ -834,7 +834,7 @@ def __init__(self, instance_id: str, registry: _Registry, entity_context: Orches
834834
self._current_utc_datetime = datetime(1000, 1, 1)
835835
self._instance_id = instance_id
836836
self._registry = registry
837-
self._entity_context = entity_context
837+
self._entity_context = OrchestrationEntityContext(instance_id)
838838
self._version: Optional[str] = None
839839
self._completion_status: Optional[pb.OrchestrationStatus] = None
840840
self._received_events: dict[str, list[Any]] = {}
@@ -1271,7 +1271,6 @@ def __init__(self, registry: _Registry, logger: logging.Logger):
12711271
self._logger = logger
12721272
self._is_suspended = False
12731273
self._suspended_events: list[pb.HistoryEvent] = []
1274-
self._entity_state: Optional[OrchestrationEntityContext] = None
12751274

12761275
def execute(
12771276
self,
@@ -1288,13 +1287,12 @@ def execute(
12881287
f"{instance_id}: Beginning replay for orchestrator {orchestration_name}..."
12891288
)
12901289

1291-
self._entity_state = OrchestrationEntityContext(instance_id)
1292-
12931290
if not new_events:
12941291
raise task.OrchestrationStateError(
12951292
"The new history event list must have at least one event in it."
12961293
)
1297-
ctx = _RuntimeOrchestrationContext(instance_id, self._registry, self._entity_state)
1294+
1295+
ctx = _RuntimeOrchestrationContext(instance_id, self._registry)
12981296
try:
12991297
# Rebuild local state by replaying old history into the orchestrator function
13001298
self._logger.debug(

0 commit comments

Comments
 (0)