class Chimp::Task
This class allows to check on the status of any of the tasks created.
Attributes
tasker[RW]
Public Class Methods
new()
click to toggle source
# File lib/right_chimp/resources/task.rb, line 12 def initialize rate = ENV['API_POLLING_RATE'] || 30 @api_polling_rate = rate.to_i end
Public Instance Methods
details()
click to toggle source
# File lib/right_chimp/resources/task.rb, line 54 def details tasker.show(view: 'extended').detail end
friendly_url()
click to toggle source
# File lib/right_chimp/resources/task.rb, line 47 def friendly_url friendly_url = Connection.audit_url + '/audit_entries/' friendly_url += href.split(/\//).last friendly_url = friendly_url.gsub('ae-', '') friendly_url end
href()
click to toggle source
# File lib/right_chimp/resources/task.rb, line 43 def href tasker.href end
state()
click to toggle source
# File lib/right_chimp/resources/task.rb, line 39 def state tasker.show.summary end
wait_for_completed(timeout = 900)
click to toggle source
# File lib/right_chimp/resources/task.rb, line 35 def wait_for_completed(timeout = 900) wait_for_state('completed', timeout) end
wait_for_state(desired_state, timeout = 900)
click to toggle source
# File lib/right_chimp/resources/task.rb, line 17 def wait_for_state(desired_state, timeout = 900) while timeout > 0 # Make compatible with RL10. status = state.downcase return true if status.match(desired_state) friendly_url = Connection.audit_url + '/audit_entries/' friendly_url += href.split(/\//).last friendly_url = friendly_url.gsub('ae-', '') if status.match('failed') || status.match('aborted') raise "FATAL error, #{status}\n\n Audit: #{friendly_url}\n " end Log.debug "Polling again in #{@api_polling_rate}" sleep @api_polling_rate timeout -= @api_polling_rate end raise "FATAL: Timeout waiting for Executable to complete. State was #{status}" if timeout <= 0 end