Class: Proxy::Dynflow::Runner::Parent
- Inherits:
-
Base
- Object
- Base
- Proxy::Dynflow::Runner::Parent
show all
- Defined in:
- lib/smart_proxy_dynflow/runner/parent.rb
Instance Attribute Summary
Attributes inherited from Base
#id, #logger
Instance Method Summary
collapse
Methods inherited from Base
#close, #external_event, #kill, #new_update, #no_update, #publish_exception, #publish_exit_status, #refresh, #run_refresh, #start, #timeout, #timeout_interval
Constructor Details
#initialize(targets = {}, suspended_action: nil) ⇒ Parent
targets = { identifier => { :execution_plan_id => “…”, :run_step_id => id,
:input => { ... } }
6
7
8
9
10
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 6
def initialize(targets = {}, suspended_action: nil)
@targets = targets
@exit_statuses = {}
super suspended_action: suspended_action
end
|
Instance Method Details
#broadcast_data(data, type) ⇒ Object
36
37
38
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 36
def broadcast_data(data, type)
@outputs.each_value { |output| output.add_output(data, type) }
end
|
#dispatch_exception(context, exception) ⇒ Object
48
49
50
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 48
def dispatch_exception(context, exception)
@outputs.each_value { |output| output.add_exception(context, exception) }
end
|
#generate_updates ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 12
def generate_updates
base = {}
base[@suspended_action] = Runner::Update.new(Proxy::Dynflow::ContinuousOutput.new, @exit_status) if @exit_status
@outputs.reject { |_, output| @exit_status.nil? && output.empty? }
.reduce(base) do |acc, (identifier, output)|
@outputs[identifier] = Proxy::Dynflow::ContinuousOutput.new exit_status = @exit_statuses[identifier] || @exit_status if @exit_status
acc.merge(host_action(identifier) => Runner::Update.new(output, exit_status))
end
end
|
#host_action(identifier) ⇒ Object
30
31
32
33
34
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 30
def host_action(identifier)
options = @targets[identifier].slice('execution_plan_id', 'run_step_id')
.merge(:world => Proxy::Dynflow::Core.world)
Dynflow::Action::Suspended.new OpenStruct.new(options)
end
|
#initialize_continuous_outputs ⇒ Object
24
25
26
27
28
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 24
def initialize_continuous_outputs
@outputs = @targets.keys.reduce({}) do |acc, target|
acc.merge(target => Proxy::Dynflow::ContinuousOutput.new)
end
end
|
#publish_data(_data, _type) ⇒ Object
40
41
42
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 40
def publish_data(_data, _type)
true
end
|
#publish_data_for(identifier, data, type) ⇒ Object
44
45
46
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 44
def publish_data_for(identifier, data, type)
@outputs[identifier].add_output(data, type)
end
|
#publish_exit_status_for(identifier, exit_status) ⇒ Object
52
53
54
|
# File 'lib/smart_proxy_dynflow/runner/parent.rb', line 52
def publish_exit_status_for(identifier, exit_status)
@exit_statuses[identifier] = exit_status
end
|