ruby aws sdk v2 SimpleWorkFlow(Aws::SWF::Client)メモ
swf = Aws::SWF::Client.new
失敗したExecutionを取り出す
WORKFLOW_DOMAIN = 'myworkflowdomain' resp = swf.list_closed_workflow_executions( domain: WORKFLOW_DOMAIN, start_time_filter: {oldest_date: 24.hours.ago}, close_status_filter: {status: 'TIMED_OUT'}) resp.execution_infos.each do |execution_info| pp execution_info # #<struct Aws::SWF::Types::WorkflowExecutionInfo # execution= # #<struct Aws::SWF::Types::WorkflowExecution # workflow_id="fcac73cf-51c2-43f7-95cd-387a0bb4338b", # run_id="22I3gtPVgL2GuGcBd9q1YvqH0D4aY66UbeQrJh+h7ExI8=">, # workflow_type= # #<struct Aws::SWF::Types::WorkflowType # name="EncodeWorkflow.encode", # version="1.20">, # start_timestamp=2016-05-19 18:21:53 +0000, # close_timestamp=2016-05-19 19:21:53 +0000, # execution_status="CLOSED", # close_status="TIMED_OUT", # parent=nil, # tag_list=[], # cancel_requested=false> execution_event = swf.get_workflow_execution_history( domain: WORKFLOW_DOMAIN, execution: execution_info.execution.to_h, maximum_page_size: 1, reverse_order: true).events.first pp execution_event # #<struct Aws::SWF::Types::HistoryEvent # event_timestamp=2016-05-19 19:21:53 +0000, # event_type="WorkflowExecutionTimedOut", # event_id=183, # workflow_execution_started_event_attributes=nil, # workflow_execution_completed_event_attributes=nil, # complete_workflow_execution_failed_event_attributes=nil, # workflow_execution_failed_event_attributes=nil, # fail_workflow_execution_failed_event_attributes=nil, # workflow_execution_timed_out_event_attributes= # #<struct Aws::SWF::Types::WorkflowExecutionTimedOutEventAttributes # timeout_type="START_TO_CLOSE", # child_policy="TERMINATE">, # workflow_execution_canceled_event_attributes=nil, # cancel_workflow_execution_failed_event_attributes=nil, # workflow_execution_continued_as_new_event_attributes=nil, # continue_as_new_workflow_execution_failed_event_attributes=nil, # workflow_execution_terminated_event_attributes=nil, # workflow_execution_cancel_requested_event_attributes=nil, # decision_task_scheduled_event_attributes=nil, # decision_task_started_event_attributes=nil, # decision_task_completed_event_attributes=nil, # decision_task_timed_out_event_attributes=nil, # activity_task_scheduled_event_attributes=nil, # activity_task_started_event_attributes=nil, # activity_task_completed_event_attributes=nil, # activity_task_failed_event_attributes=nil, # activity_task_timed_out_event_attributes=nil, # activity_task_canceled_event_attributes=nil, # activity_task_cancel_requested_event_attributes=nil, # workflow_execution_signaled_event_attributes=nil, # marker_recorded_event_attributes=nil, # record_marker_failed_event_attributes=nil, # timer_started_event_attributes=nil, # timer_fired_event_attributes=nil, # timer_canceled_event_attributes=nil, # start_child_workflow_execution_initiated_event_attributes=nil, # child_workflow_execution_started_event_attributes=nil, # child_workflow_execution_completed_event_attributes=nil, # child_workflow_execution_failed_event_attributes=nil, # child_workflow_execution_timed_out_event_attributes=nil, # child_workflow_execution_canceled_event_attributes=nil, # child_workflow_execution_terminated_event_attributes=nil, # signal_external_workflow_execution_initiated_event_attributes=nil, # external_workflow_execution_signaled_event_attributes=nil, # signal_external_workflow_execution_failed_event_attributes=nil, # external_workflow_execution_cancel_requested_event_attributes=nil, # request_cancel_external_workflow_execution_initiated_event_attributes=nil, # request_cancel_external_workflow_execution_failed_event_attributes=nil, # schedule_activity_task_failed_event_attributes=nil, # request_cancel_activity_task_failed_event_attributes=nil, # start_timer_failed_event_attributes=nil, # cancel_timer_failed_event_attributes=nil, # start_child_workflow_execution_failed_event_attributes=nil, # lambda_function_scheduled_event_attributes=nil, # lambda_function_started_event_attributes=nil, # lambda_function_completed_event_attributes=nil, # lambda_function_failed_event_attributes=nil, # lambda_function_timed_out_event_attributes=nil, # schedule_lambda_function_failed_event_attributes=nil, # start_lambda_function_failed_event_attributes=nil> end
再実行
# 最初のイベントにワークフロー開始時の属性が入っているのでそれを使うことにした execution_started_event_attributes = swf.get_workflow_execution_history( domain: WORKFLOW_DOMAIN, execution: execution_info.execution.to_h, maximum_page_size: 1, reverse_order: false).events.first.workflow_execution_started_event_attributes re_run_id = swf.start_workflow_execution({ domain: WORKFLOW_DOMAIN, workflow_id: execution_info.execution.workflow_id, workflow_type: execution_info.workflow_type.to_h, task_list: execution_started_event_attributes.task_list, task_priority: execution_started_event_attributes.task_priority, input: execution_started_event_attributes.input, execution_start_to_close_timeout: execution_started_event_attributes.execution_start_to_close_timeout, tag_list: execution_started_event_attributes.tag_list, task_start_to_close_timeout: execution_started_event_attributes.task_start_to_close_timeout, child_policy: execution_started_event_attributes.child_policy, lambda_role: execution_started_event_attributes.lambda_role, }).run_id pp re_run_id # => "22K7jh/0kr9D4MGohM6aAESvZXkwuJg8WN3dN28silj1U="