5
5
"""
6
6
from typing import Callable , Iterator , Any , Generator
7
7
8
+ from azure .durable_functions .models .ReplaySchema import ReplaySchema
9
+
8
10
from .models import (
9
11
DurableOrchestrationContext ,
10
12
Task ,
@@ -55,6 +57,7 @@ def handle(self, context: DurableOrchestrationContext):
55
57
# `fn_output` is the return value instead of a generator
56
58
if not isinstance (fn_output , Iterator ):
57
59
orchestration_state = OrchestratorState (
60
+ replay_schema = self .durable_context ._replay_schema ,
58
61
is_done = True ,
59
62
output = fn_output ,
60
63
actions = self .durable_context .actions ,
@@ -75,6 +78,7 @@ def handle(self, context: DurableOrchestrationContext):
75
78
# `will_continue_as_new` essentially "tracks"
76
79
# whether or not the orchestration is done.
77
80
orchestration_state = OrchestratorState (
81
+ replay_schema = self .durable_context ._replay_schema ,
78
82
is_done = self .durable_context .will_continue_as_new ,
79
83
output = None ,
80
84
actions = self .durable_context .actions ,
@@ -95,13 +99,15 @@ def handle(self, context: DurableOrchestrationContext):
95
99
96
100
except StopIteration as sie :
97
101
orchestration_state = OrchestratorState (
102
+ replay_schema = self .durable_context ._replay_schema ,
98
103
is_done = True ,
99
104
output = sie .value ,
100
105
actions = self .durable_context .actions ,
101
106
custom_status = self .durable_context .custom_status )
102
107
except Exception as e :
103
108
exception_str = str (e )
104
109
orchestration_state = OrchestratorState (
110
+ replay_schema = self .durable_context ._replay_schema ,
105
111
is_done = False ,
106
112
output = None , # Should have no output, after generation range
107
113
actions = self .durable_context .actions ,
@@ -135,12 +141,17 @@ def _add_to_actions(self, generation_state):
135
141
if self .durable_context .will_continue_as_new :
136
142
return
137
143
if not generation_state ._is_yielded :
138
- if (isinstance (generation_state , Task )
139
- and hasattr (generation_state , "action" )):
140
- self .durable_context .actions .append ([generation_state .action ])
141
- elif (isinstance (generation_state , TaskSet )
142
- and hasattr (generation_state , "actions" )):
143
- self .durable_context .actions .append (generation_state .actions )
144
+ if isinstance (generation_state , Task ):
145
+ if self .durable_context ._replay_schema == ReplaySchema .V1 :
146
+ self .durable_context .actions .append ([generation_state .action ])
147
+ else :
148
+ self .durable_context .actions [0 ].append (generation_state .action )
149
+
150
+ elif isinstance (generation_state , TaskSet ):
151
+ if self .durable_context ._replay_schema == ReplaySchema .V1 :
152
+ self .durable_context .actions .append (generation_state .actions )
153
+ else :
154
+ self .durable_context .actions [0 ].append (generation_state .actions )
144
155
generation_state ._is_yielded = True
145
156
146
157
def _update_timestamp (self ):
0 commit comments