diff --git a/lib/smart_proxy_dynflow/continuous_output.rb b/lib/smart_proxy_dynflow/continuous_output.rb index 5bfa511..cfe5c0d 100644 --- a/lib/smart_proxy_dynflow/continuous_output.rb +++ b/lib/smart_proxy_dynflow/continuous_output.rb @@ -37,18 +37,20 @@ def humanize raw_outputs.map { |output| output['output'] }.join("\n") end - def add_exception(context, exception, timestamp = Time.now.getlocal) - add_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp) + def add_exception(context, exception, timestamp: Time.now.getlocal, id: nil) + add_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp: timestamp, id: id) end - def add_output(*args) - add_raw_output(self.class.format_output(*args)) + def add_output(*args, **kwargs) + add_raw_output(self.class.format_output(*args, **kwargs)) end - def self.format_output(message, type = 'debug', timestamp = Time.now.getlocal) - { 'output_type' => type, - 'output' => message, - 'timestamp' => timestamp.to_f } + def self.format_output(message, type = 'debug', timestamp: Time.now.getlocal, id: nil) + base = { 'output_type' => type, + 'output' => message, + 'timestamp' => timestamp.to_f } + base['id'] = id if id + base end end end diff --git a/lib/smart_proxy_dynflow/runner/base.rb b/lib/smart_proxy_dynflow/runner/base.rb index ac5341a..372e9e7 100644 --- a/lib/smart_proxy_dynflow/runner/base.rb +++ b/lib/smart_proxy_dynflow/runner/base.rb @@ -58,8 +58,8 @@ def timeout_interval # or nil for no timeout end - def publish_data(data, type) - @continuous_output.add_output(data, type) + def publish_data(...) + @continuous_output.add_output(...) end def publish_exception(context, exception, fatal = true) diff --git a/lib/smart_proxy_dynflow/runner/parent.rb b/lib/smart_proxy_dynflow/runner/parent.rb index fe81dd7..61955f9 100644 --- a/lib/smart_proxy_dynflow/runner/parent.rb +++ b/lib/smart_proxy_dynflow/runner/parent.rb @@ -35,16 +35,16 @@ def host_action(identifier) Dynflow::Action::Suspended.new OpenStruct.new(options) end - def broadcast_data(data, type) - @outputs.each_value { |output| output.add_output(data, type) } + def broadcast_data(...) + @outputs.each_value { |output| output.add_output(...) } end def publish_data(_data, _type) true end - def publish_data_for(identifier, data, type) - @outputs[identifier].add_output(data, type) + def publish_data_for(identifier, data, type, **kwargs) + @outputs[identifier].add_output(data, type, **kwargs) end def dispatch_exception(context, exception)