Sha256: cf110428d74d5ae0c4889227c03db6cbdd369d4de2eb254f79eff2483f295c0b
Contents?: true
Size: 1.2 KB
Versions: 15
Compression:
Stored size: 1.2 KB
Contents
module Rearview class ResultsHandler attr_reader :status,:job,:monitor_results include Rearview::Logger def initialize(job,monitor_results) @job = job @status = Job::Status::ERROR @monitor_results = monitor_results || {} end def run logger.info "#{self} run" normalized_results = Rearview::MonitorRunner.normalize_results(@monitor_results) @status = normalized_results[:status] || @status job_data = JobData.find_or_create_by(job_id: @job.id) job_data.data = normalized_results job_data.save! @job.last_run = Time.now.utc event = if Job::Status.values.include?(@status.to_s) @status.to_sym else :error end logger.info "#{self} firing event :#{event} for #{@job.inspect}" @job.fire_event(event,{:monitor_results=>@monitor_results,:job_error=>{:message=>normalized_results[:output]}}) self rescue logger.error "#{self} process results failed: #{$!}\n#{$@.join("\n")}" self end end def to_s "#{super.to_s} [jobId:#{@job.id} threadId:#{java.lang.Thread.currentThread.getId} threadName:#{java.lang.Thread.currentThread.getName}]" end end
Version data entries
15 entries across 15 versions & 1 rubygems