まぁドキュメントにあるんですが忘れるんでメモ。英語つらい
Retrying Failed Tasks - AWS Flow Framework for Ruby
使い方がおかしかったらご指摘頂けると助かります…
class ExampleWorkflow extend AWS::Flow::Workflows workflow :start do { version: '1.0', task_list: 'example_wf_tasklist', execution_start_to_close_timeout: 300, task_start_to_close_timeout: 120 } end activity_client :client do { from_class: 'ExampleActivity' } end class InfiniteRetry < RuntimeError; end def start(video_id) retry_options = { exponential_retry: { maximum_attempts: 5, retries_per_exception: { InfiniteRetry => Float::INFINITY, RuntimeError => 5, } } } AWS::Flow::with_retry(retry_options) do begin client.activate!(video_id) rescue AWS::Flow::ActivityTaskTimedOutException => e # SCHEDULE_TO_START # START_TO_CLOSE # 今回は時間内に実行できなかった、完了しなかったケースは繰り返したい raise InfiniteRetry rescue AWS::Flow::ActivityTaskFailedException => e # タスクの実行に失敗した場合はとりあえず数回繰り返してみる raise RuntimeError rescue => e # それ以外はそこで終了 raise e end end end end
タスク実行の際のエラークラスについて
AWS::Flow::ActivityTaskTimedOutException
This class is abstract.
An exception raised when the activity task has timed out.
AWS::Flow::ActivityTaskFailedException
This class is abstract.
An exception raised when the activity task has failed.