Skip to content

Commit 06ba8e1

Browse files
committed
Add 'attempt' count in simpleflow History
1 parent 3f90c67 commit 06ba8e1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

simpleflow/history.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def get_activity():
156156
}
157157
if event.activity_id not in self._activities:
158158
activity["retry"] = 0
159+
activity["attempt"] = 1
159160
self._activities[event.activity_id] = activity
160161
self._tasks.append(activity)
161162
else:
@@ -166,6 +167,7 @@ def get_activity():
166167
# corresponds to the last execution.
167168
self._activities[event.activity_id].update(activity)
168169
self._activities[event.activity_id]["retry"] += 1
170+
self._activities[event.activity_id]["attempt"] += 1
169171
elif event.state == "schedule_failed":
170172
activity = {
171173
"type": "activity",
@@ -305,6 +307,7 @@ def get_workflow():
305307
}
306308
if event.workflow_id not in self._child_workflows:
307309
workflow["retry"] = 0
310+
workflow["attempt"] = 1
308311
self._child_workflows[event.workflow_id] = workflow
309312
self._tasks.append(workflow)
310313
else:
@@ -318,6 +321,7 @@ def get_workflow():
318321
)
319322
self._child_workflows[event.workflow_id].update(workflow)
320323
self._child_workflows[event.workflow_id]["retry"] += 1
324+
self._child_workflows[event.workflow_id]["attempt"] += 1
321325
elif event.state == "start_failed":
322326
workflow = {
323327
"type": "child_workflow",

simpleflow/swf/mapper/models/event/task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ActivityTaskEventDict(TypedDict):
6666
activity_id: int
6767
activity_type: ActivityType
6868
retry: int | None
69+
attempt: int | None
6970
cause: str
7071
result: Any
7172
reason: str | None

0 commit comments

Comments
 (0)