1

It seems that all SWF operations for getting execution state always also need the runId (their reference to the workflow execution), and I don't feel like storing that. I want to be able to do a lookup based on workflowId only (my id, not theirs). Is anything like that possible at all?

I mean, I guess I could add some tags to retrieve it by tags, but that seems a little awkward, if I already passed the workflowId as well.

4

1 回答 1

3

是的,根据ListOpenWorkflowExecutions API 文档,用户可以按 workflowId 过滤打开的执行。

一个 Python 示例,使用boto.swf(使用这篇文章中的 1. 来设置域):

$ ipython
Python 2.7.3(默认,2013 年 4 月 10 日,06:20:15)
输入“copyright”、“credits”或“license”以获取更多信息。

[1]中:将boto.swf.layer2导入为swf

在 [2] 中:域 = swf.Domain(name='stackoverflow')

在 [3] 中:domain.workflows()
Out[3]: [ WorkflowType 'MyWorkflow-1.0' at 0x32a44d0 ]

在 [4] 中:myworkflow = domain.workflows()[0]

在 [5] 中:执行 = myworkflow.start(workflow_id='my_wf_id', task_list='default')

[6] 中:other_execution = myworkflow.start(workflow_id='some_other_wf_id', task_list='default')

在 [7] 中:domain.executions()
出[7]:
[ WorkflowExecution 'MyWorkflow-1.0' 在 0x32a4910 ,
  WorkflowExecution 'MyWorkflow-1.0' 在 0x32ac090 ,
  WorkflowExecution 'MyWorkflow-1.0' at 0x32ac210]

在[8]中:execution.describe()
输出[8]:
{'executionConfiguration': {'childPolicy': 'TERMINATE',
  'executionStartToCloseTimeout': '3600',
  'taskList': {'name': 'default'},
  'taskStartToCloseTimeout': '300'},
 'executionInfo':{'cancelRequested':假,
  '执行':{'runId':'...',
   'workflowId': 'my_wf_id'},
  “执行状态”:“打开”,
  “开始时间戳”:1374482188.063,
  'workflowType': {'name': 'MyWorkflow', 'version': '1.0'}},
 'openCounts': {'openActivityTasks': 0,
  'openChildWorkflowExecutions': 0,
  'openDecisionTasks': 1,
  'openTimers':0}}

在 [9] 中:domain.executions(workflow_id='my_wf_id')
出 [9]: [工作流执行 'MyWorkflow-1.0' 在 0x344fad0 ]

在 [10] 中:domain.executions(workflow_id='my_wf_id')[0].describe()
输出[10]:
{'executionConfiguration': {'childPolicy': 'TERMINATE',
  'executionStartToCloseTimeout': '3600',
  'taskList': {'name': 'default'},
  'taskStartToCloseTimeout': '300'},
 'executionInfo':{'cancelRequested':假,
  '执行':{'runId':'...',
   'workflowId': 'my_wf_id'},
  “执行状态”:“打开”,
  “开始时间戳”:1374482188.063,
  'workflowType': {'name': 'MyWorkflow', 'version': '1.0'}},
 'openCounts': {'openActivityTasks': 0,
  'openChildWorkflowExecutions': 0,
  'openDecisionTasks': 1,
  'openTimers':0}}
于 2013-07-22T08:51:59.367 回答