Sha256: f76db034a54a5c52dcf15171f4fb10bdd0ff951dfb6c3060af12e053b216686f
Contents?: true
Size: 1.58 KB
Versions: 32
Compression:
Stored size: 1.58 KB
Contents
module Actions module RemoteExecution class ProxyAction < ::Actions::ProxyAction include Actions::RemoteExecution::TemplateInvocationProgressLogging def on_data(data, meta = {}) super process_proxy_data(output[:proxy_output]) end def run(event = nil) with_template_invocation_error_logging { super } end private def get_proxy_data(response) data = super process_proxy_data(data) data end def process_proxy_data(data) events = data['result'].each_with_index.map do |update, seq_id| { # For N-1 compatibility, we assume that the output provided here is # complete sequence_id: update['sequence_id'] || seq_id, template_invocation_id: template_invocation.id, event: update['output'], timestamp: Time.at(update['timestamp']).getlocal, event_type: update['output_type'], } end if data['exit_status'] last = events.last || {:sequence_id => -1, :timestamp => Time.zone.now} events << { sequence_id: last[:sequence_id] + 1, template_invocation_id: template_invocation.id, event: data['exit_status'], timestamp: last[:timestamp], event_type: 'exit', } end events.each_slice(1000) do |batch| TemplateInvocationEvent.upsert_all(batch, unique_by: [:template_invocation_id, :sequence_id]) # rubocop:disable Rails/SkipsModelValidations end end end end end
Version data entries
32 entries across 32 versions & 1 rubygems