Add SWF endpoint CountPendingActivityTasks
This commit is contained in:
parent
761ab816f9
commit
08643945df
3 changed files with 42 additions and 1 deletions
|
|
@ -287,6 +287,17 @@ class SWFBackend(BaseBackend):
|
|||
else:
|
||||
return None
|
||||
|
||||
def count_pending_activity_tasks(self, domain_name, task_list):
|
||||
self._check_string(domain_name)
|
||||
self._check_string(task_list)
|
||||
domain = self._get_domain(domain_name)
|
||||
count = 0
|
||||
for _task_list, tasks in domain.activity_task_lists.iteritems():
|
||||
if _task_list == task_list:
|
||||
pending = [t for t in tasks if t.state in ["SCHEDULED", "STARTED"]]
|
||||
count += len(pending)
|
||||
return count
|
||||
|
||||
|
||||
swf_backends = {}
|
||||
for region in boto.swf.regions():
|
||||
|
|
|
|||
|
|
@ -242,7 +242,6 @@ class SWFResponse(BaseResponse):
|
|||
count = self.swf_backend.count_pending_decision_tasks(domain_name, task_list)
|
||||
return json.dumps({"count": count, "truncated": False})
|
||||
|
||||
|
||||
def respond_decision_task_completed(self):
|
||||
task_token = self._params["taskToken"]
|
||||
execution_context = self._params.get("executionContext")
|
||||
|
|
@ -265,3 +264,9 @@ class SWFResponse(BaseResponse):
|
|||
)
|
||||
else:
|
||||
return json.dumps({"startedEventId": 0})
|
||||
|
||||
def count_pending_activity_tasks(self):
|
||||
domain_name = self._params["domain"]
|
||||
task_list = self._params["taskList"]["name"]
|
||||
count = self.swf_backend.count_pending_activity_tasks(domain_name, task_list)
|
||||
return json.dumps({"count": count, "truncated": False})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue