Class: CI::Queue::Redis::GrindRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/queue/redis/grind_record.rb

Instance Method Summary collapse

Constructor Details

#initialize(queue, redis, config) ⇒ GrindRecord

Returns a new instance of GrindRecord.



7
8
9
10
11
# File 'lib/ci/queue/redis/grind_record.rb', line 7

def initialize(queue, redis, config)
  @queue = queue
  @redis = redis
  @config = config
end

Instance Method Details

#error_reportsObject Also known as: failed_tests



32
33
34
# File 'lib/ci/queue/redis/grind_record.rb', line 32

def error_reports
  redis.lrange(key('error-reports'), 0, -1)
end

#fetch_stats(stat_names) ⇒ Object



36
37
38
39
40
41
# 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_warningsObject



43
44
45
# File 'lib/ci/queue/redis/grind_record.rb', line 43

def pop_warnings
  []
end

#record_error(payload, stats: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# 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) ⇒ Object



24
25
26
# File 'lib/ci/queue/redis/grind_record.rb', line 24

def record_success(stats: nil)
  record_stats(stats)
end

#record_warning(_, _) ⇒ Object



28
29
30
# File 'lib/ci/queue/redis/grind_record.rb', line 28

def record_warning(_,_)
  #do nothing
end