Sha256: f3dd8e0b1b2fde220f2a315a7011bc55381e53a6130143e9f27a47269d2d60e4
Contents?: true
Size: 1.43 KB
Versions: 18
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true module CI module Queue module Redis class GrindRecord def initialize(queue, redis, config) @queue = queue @redis = redis @config = config end def record_error(payload, stats: nil) redis.pipelined do redis.lpush( key('error-reports'), payload.force_encoding(Encoding::BINARY), ) record_stats(stats) end nil end def record_success(stats: nil) record_stats(stats) end def record_warning(_,_) #do nothing end def error_reports redis.lrange(key('error-reports'), 0, -1) end def fetch_stats(stat_names) counts = redis.pipelined do stat_names.each { |c| redis.hvals(key(c)) } end stat_names.zip(counts.map { |values| values.map(&:to_f).inject(:+).to_f }).to_h end def pop_warnings [] end alias failed_tests error_reports private attr_reader :redis, :config def key(*args) ['build', config.build_id, *args].join(':') end def record_stats(stats) return unless stats stats.each do |stat_name, stat_value| redis.hset(key(stat_name), config.worker_id, stat_value) end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems