Sha256: 9f2f7664340a246e7e469ba532059cb87ae1924b03c969d5f805986d419a5311
Contents?: true
Size: 1.51 KB
Versions: 10
Compression:
Stored size: 1.51 KB
Contents
module Kuroko2 module Workflow module Task class Retry < Base def execute retry_option = parse_option(option) token.context['RETRY'] ||= {} node.children.each do |child| token.context['RETRY'][child.path] = { retried_count: 0, count: retry_option['count'].to_i, sleep_time: retry_option['sleep_time'].to_i } end :next end def validate retry_option = parse_option(option) unless retry_option.has_key?("count") raise Workflow::AssertionError, "Syntax error option value of retry: #{option} [count option is required]" end end private # e.g count=5 sleep_time=30 def parse_option(option) raise_assertion_error unless option retry_option = { "sleep_time" => 0 } scanner = StringScanner.new(option) until scanner.eos? if scanner.scan(/count=(\d+)/) retry_option["count"] = scanner[1].to_i elsif scanner.scan(/sleep_time=(\d+)/) retry_option["sleep_time"] = scanner[1].to_i elsif scanner.scan(/\s+|,/) # do nothing else raise_assertion_error end end retry_option end def raise_assertion_error raise Workflow::AssertionError, "Syntax error option value of retry: #{option}" end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems