Class: Chimp::Task
- Inherits:
-
Object
- Object
- Chimp::Task
- Defined in:
- lib/right_chimp/objects/ChimpObjects.rb
Overview
This class allows to check on the status of any of the tasks created.
Instance Attribute Summary collapse
-
#tasker ⇒ Object
Returns the value of attribute tasker.
Instance Method Summary collapse
- #href ⇒ Object
- #state ⇒ Object
- #wait_for_completed(timeout = 900) ⇒ Object
- #wait_for_state(desired_state, timeout = 900) ⇒ Object
Instance Attribute Details
#tasker ⇒ Object
Returns the value of attribute tasker.
285 286 287 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 285 def tasker @tasker end |
Instance Method Details
#href ⇒ Object
310 311 312 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 310 def href self.tasker.href end |
#state ⇒ Object
306 307 308 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 306 def state self.tasker.show.summary end |
#wait_for_completed(timeout = 900) ⇒ Object
302 303 304 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 302 def wait_for_completed(timeout=900) wait_for_state("completed", timeout) end |
#wait_for_state(desired_state, timeout = 900) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 287 def wait_for_state(desired_state, timeout=900) while(timeout > 0) state=self.tasker.show.summary return true if self.state.match(desired_state) friendly_url = "https://"+Connection.endpoint+"/audit_entries/" friendly_url += self.href.split(/\//).last friendly_url = friendly_url.gsub("ae-","") # raise "FATAL error, #{self.tasker.show.summary}\n See Audit: API:#{self.href}, WWW:<a href='#{friendly_url}'>#{friendly_url}</a>\n " if self.state.match("failed") raise "FATAL error, #{self.tasker.show.summary}\n See Audit: #{friendly_url}'\n " if self.state.match("failed") sleep 30 timeout -= 30 end raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end |