class CI::Queue::Redis::GrindRecord

Attributes

config[R]
redis[R]

Public Class Methods

new(queue, redis, config) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 7
def initialize(queue, redis, config)
  @queue = queue
  @redis = redis
  @config = config
end

Public Instance Methods

error_reports() click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 32
def error_reports
  redis.lrange(key('error-reports'), 0, -1)
end
Also aliased as: failed_tests
failed_tests()
Alias for: error_reports
fetch_stats(stat_names) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 36
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
pop_warnings() click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 43
def pop_warnings
  []
end
record_error(payload, stats: nil) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 13
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
record_success(stats: nil) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 24
def record_success(stats: nil)
  record_stats(stats)
end
record_warning(_,_) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 28
def record_warning(_,_)
  #do nothing
end

Private Instance Methods

key(*args) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 53
def key(*args)
  ['build', config.build_id, *args].join(':')
end
record_stats(stats) click to toggle source
# File lib/ci/queue/redis/grind_record.rb, line 57
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