Sha256: 65e7574cb884b38e2a88a1d42415ad5da82bf9f87a0f543dd8607fdc4b87f5f1
Contents?: true
Size: 1.63 KB
Versions: 42
Compression:
Stored size: 1.63 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 |pipeline| pipeline.lpush( key('error-reports'), payload.force_encoding(Encoding::BINARY), ) pipeline.expire(key('error-reports'), config.redis_ttl) record_stats(stats, pipeline: pipeline) 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 |pipeline| stat_names.each { |c| pipeline.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, pipeline: redis) return unless stats stats.each do |stat_name, stat_value| pipeline.hset(key(stat_name), config.worker_id, stat_value) pipeline.expire(key(stat_name), config.redis_ttl) end end end end end end
Version data entries
42 entries across 42 versions & 1 rubygems