Skip to content

Commit

Permalink
Fixes #37319 - Allow setting IDs for outputs
Browse files Browse the repository at this point in the history
and switch runner output interface to be keyword based.
  • Loading branch information
adamruzicka committed Apr 5, 2024
1 parent c2964a6 commit 2455675
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions lib/smart_proxy_dynflow/continuous_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/smart_proxy_dynflow/runner/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions lib/smart_proxy_dynflow/runner/parent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2455675

Please sign in to comment.