Class: Choria::Orchestrator::Task::ResultSet

Inherits:
Object
  • Object
show all
Defined in:
lib/choria/orchestrator/task/result_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(on_result:) ⇒ ResultSet

Returns a new instance of ResultSet.



11
12
13
14
15
# File 'lib/choria/orchestrator/task/result_set.rb', line 11

def initialize(on_result:)
  @results = []
  @on_result = on_result
  @pending_count = 0
end

Instance Attribute Details

#pending_countObject

Returns the value of attribute pending_count.



9
10
11
# File 'lib/choria/orchestrator/task/result_set.rb', line 9

def pending_count
  @pending_count
end

#resultsObject (readonly)

Returns the value of attribute results.



7
8
9
# File 'lib/choria/orchestrator/task/result_set.rb', line 7

def results
  @results
end

Instance Method Details

#integrate_result(result) ⇒ Object



23
24
25
26
27
# File 'lib/choria/orchestrator/task/result_set.rb', line 23

def integrate_result(result)
  structured_result = Choria::Colt::DataStructurer.structure(result).with_indifferent_access
  @results << structured_result
  @on_result&.call(structured_result, @results.count, pending_count + @results.count)
end

#integrate_rpc_error(rpc_error) ⇒ Object



17
18
19
20
21
# File 'lib/choria/orchestrator/task/result_set.rb', line 17

def integrate_rpc_error(rpc_error)
  result = rpc_error[:body]
  result[:sender] = rpc_error[:senderid]
  integrate_result(result)
end