Skip to content

Commit 4557c15

Browse files
committed
Move version check to process_event
1 parent c60e9bb commit 4557c15

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

durabletask/worker.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -980,23 +980,6 @@ def execute(
980980
for old_event in old_events:
981981
self.process_event(ctx, old_event)
982982

983-
# Process versioning if applicable
984-
execution_started_events = [e.executionStarted for e in old_events if e.HasField("executionStarted")]
985-
# We only check versioning if there are executionStarted events - otherwise, on the first replay when
986-
# ctx.version will be Null, we may invalidate orchestrations early depending on the versioning strategy.
987-
if self._registry.versioning and len(execution_started_events) > 0:
988-
version_failure = self.evaluate_orchestration_versioning(
989-
self._registry.versioning,
990-
ctx.version
991-
)
992-
if version_failure:
993-
self._logger.warning(
994-
f"Orchestration version did not meet worker versioning requirements. "
995-
f"Error action = '{self._registry.versioning.failure_strategy}'. "
996-
f"Version error = '{version_failure}'"
997-
)
998-
raise pe.VersionFailureException
999-
1000983
# Get new actions by executing newly received events into the orchestrator function
1001984
if self._logger.level <= logging.DEBUG:
1002985
summary = _get_new_event_summary(new_events)
@@ -1068,6 +1051,19 @@ def process_event(
10681051
if event.executionStarted.version:
10691052
ctx._version = event.executionStarted.version.value
10701053

1054+
if self._registry.versioning:
1055+
version_failure = self.evaluate_orchestration_versioning(
1056+
self._registry.versioning,
1057+
ctx.version
1058+
)
1059+
if version_failure:
1060+
self._logger.warning(
1061+
f"Orchestration version did not meet worker versioning requirements. "
1062+
f"Error action = '{self._registry.versioning.failure_strategy}'. "
1063+
f"Version error = '{version_failure}'"
1064+
)
1065+
raise pe.VersionFailureException
1066+
10711067
# deserialize the input, if any
10721068
input = None
10731069
if (

0 commit comments

Comments
 (0)