Skip to content
This repository was archived by the owner on Apr 12, 2018. It is now read-only.

Commit 942a2a3

Browse files
committed
Update models.history.builder: add History.add_activity_task_timed_out()
1 parent ffb8d24 commit 942a2a3

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

swf/models/history/builder.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,27 @@ def add_activity_task_failed(self,
271271

272272
return self
273273

274+
def add_activity_task_timed_out(self,
275+
timeout_type,
276+
scheduled=None,
277+
started=None):
278+
if scheduled is None:
279+
scheduled = self.last_id - 1
280+
281+
if started is None:
282+
started = self.last_id
283+
284+
self.events.append(EventFactory({
285+
'eventId': self.next_id,
286+
'eventTimestamp': new_timestamp_string(),
287+
'eventType': 'ActivityTaskTimedOut',
288+
'activityTaskTimedOutEventAttributes': {
289+
'scheduledEventId': scheduled,
290+
'startedEventId': started,
291+
'timeoutType': timeout_type,
292+
}
293+
}))
294+
274295
def add_activity_task(self,
275296
activity,
276297
decision_id,
@@ -280,7 +301,8 @@ def add_activity_task(self,
280301
control=None,
281302
result=None,
282303
reason=DEFAULT_REASON,
283-
details=DEFAULT_DETAILS):
304+
details=DEFAULT_DETAILS,
305+
timeout_type='START_TO_CLOSE'):
284306
self.add_activity_task_scheduled(
285307
activity,
286308
decision_id,
@@ -307,6 +329,11 @@ def add_activity_task(self,
307329
started=started_id,
308330
reason=reason,
309331
details=details)
332+
elif last_state == 'timed_out':
333+
self.add_activity_task_timed_out(
334+
scheduled=scheduled_id,
335+
started=started_id,
336+
timeout_type=timeout_type)
310337
else:
311338
raise ValueError('last state {} is not supported'.format(
312339
last_state))

0 commit comments

Comments
 (0)