Class: Executrix::Batch
- Inherits:
-
Object
- Object
- Executrix::Batch
- Defined in:
- lib/executrix/batch.rb
Instance Method Summary collapse
- #final_status(poll_interval = 2) ⇒ Object
-
#initialize(connection, job_id, batch_id) ⇒ Batch
constructor
A new instance of Batch.
- #results ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(connection, job_id, batch_id) ⇒ Batch
Returns a new instance of Batch.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/executrix/batch.rb', line 3 def initialize connection, job_id, batch_id @connection = connection @job_id = job_id @batch_id = batch_id if @batch_id == -1 @final_status = { state: 'Completed', state_message: 'Empty Request' } end end |
Instance Method Details
#final_status(poll_interval = 2) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/executrix/batch.rb', line 16 def final_status poll_interval=2 return @final_status if @final_status @final_status = self.status while ['Queued', 'InProgress'].include?(@final_status[:state]) sleep poll_interval @final_status = self.status yield @final_status if block_given? end raise @final_status[:state_message] if @final_status[:state] == 'Failed' @final_status.merge({ results: results }) end |
#results ⇒ Object
37 38 39 40 |
# File 'lib/executrix/batch.rb', line 37 def results init_result_id @connection.query_batch_result_data(@job_id, @batch_id, @result_id) end |
#status ⇒ Object
33 34 35 |
# File 'lib/executrix/batch.rb', line 33 def status @connection.query_batch @job_id, @batch_id end |